2017 © Pedro Peláez
 

library podio-auth

Podio authentication including rate-limit controlling

image

rijosh/podio-auth

Podio authentication including rate-limit controlling

  • Thursday, February 22, 2018
  • by rijosh
  • Repository
  • 0 Watchers
  • 0 Stars
  • 88 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 21 Versions
  • 11 % Grown

The README.md

Laravel-Podio Auth

Laravel-Podio library which includes * Username and password flow * App authentication flow * Podio API library * Podio rate-limit handling * Podio app hook handling, (*1)

Prerequisites

  • php: ^5.3.0
  • laravel/framework: ^5.2
  • podio/podio-php: ^4.3

Installing

  1. Install package composer require rijosh/podio-auth
  2. Include the PodioAuthServiceProvider in config/app.php provider list, (*2)

    PodioAuth\PodioAuthServiceProvider::class
    
  3. Create config file podio.php and add the following code:, (*3)

    return [
       /**
        * Podio username and password.
        * This will be using for user authentication (Username and password flow).
        */
       'username' => '',
       'password' => '',
    
    
       /**
        * Include Podio apps details here.
        * This will be using for app authentication (App authentication flow).
        * List the type of hooks if needed.
        */
       'app_auth' => [
           'app_name' => [
               'app_id' =>,
               'app_secret' => '',
               'hook_types' => []
           ],
       ],
    
    
       /**
        * Include multiple API Keys here.
        * This is using for rate-limit handling.
        */
       'client_api' => [
           [
               'id' => '',
               'secret' => '',
           ],
       ]
    ];
    
  4. Update podio.php with configuration data.
  5. Run the following commands, (*4)

    * php artisan podio:init
    
    

    This will generate the required tables and sync the api from config., (*5)

Code Examples

Use package library for authentication and Podio API, (*6)

 <?php

 namespace App\Http\Controllers;


 use PodioAuth\Controllers\PodioAuth;
 use PodioAuth\Repositories\Podio;

 class TestController extends Controller
 {
     public function getTest()
     {
         PodioAuth::podioUserAuth(); // username-password authentication
         PodioAuth::podioAppAuth(12344); // App authentication
         PodioAuth::podioAppAuthWithName("name"); // Authenticate app with name specified in config/podio.php
         Podio::PodioApp_get(123456); // Get Podio app details
     }
 }

Using hook management module

The following urls can be used to manage Podio hooks., (*7)

  • hook/create : Add hooks to all Podio apps listed in the config file.
  • hook/remove : Remove all hooks added from the application independent of the entries created in podio_hooks table.
  • hook/disable : Remove all hooks from Podio apps that listed in the podio_hooks table.
  • cron/hook : Use this url as a cron job. It will check for inactive hooks in apps and enable them.

After adding the hooks, make sure all hooks are verified. The hook url will be handle/{app_id}/hook. All the hooks from Podio will be entered into the podio_requests table and trigger the hook processing url. This will help to process hooks asynchronously. Follow the steps to continue with the hook processing. * Create new controller and extend PodioAuth\Controllers\HookController. * Add function to process the hooks., (*8)

    public function processHook($id) // table row id
    {
        $request = PodioRequest::whereId($id)->first(); 
        if ($request) {
            $appId = $request->app_id;
            $hook = $request->request;


            /**
            * Start processing hook.
            */
            $request->is_processing = 1;
            $request->save();


            /**
            * Your code
            */


            /**
            * Finished processing hook.
            */
            $request->is_processing = 0;
            $request->is_processed = 1;
            $request->save();
        }
    }
  • Add route for this function with name process_hook and method as get.
Route::get('process/{id}/hook', 'HookController@processHook')->name('process_hook');

Note

All the functionalities are working depending on the configuration data in the podio.php file. Make sure app_auth and client_api are correctly synced to corresponding tables in database. Clear the configuration cache by running the command php artisan config:cache., (*9)

Contributing

Contributions to Podio Auth library are welcome., (*10)

The Versions

22/02 2018

dev-master

9999999-dev

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.8

1.3.8.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.7

1.3.7.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.5

1.3.5.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.6

1.3.6.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.4

1.3.4.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.1

1.3.1.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.2

1.3.2.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

22/02 2018

1.3.3

1.3.3.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

21/02 2018

1.3.0

1.3.0.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

04/10 2017

1.1.0

1.1.0.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

20/09 2017

1.0.9

1.0.9.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

20/09 2017

1.0.8

1.0.8.0

Podio authentication including rate-limit controlling

  Sources   Download

MIT

The Requires

 

by Avatar rijosh

20/09 2017

1.0.7

1.0.7.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

12/07 2017

1.0.6

1.0.6.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

12/07 2017

1.0.5

1.0.5.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

12/07 2017

1.0.4

1.0.4.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

11/07 2017

1.0.3

1.0.3.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

11/07 2017

1.0.2

1.0.2.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

11/07 2017

1.0.1

1.0.1.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh

11/07 2017

1.0.0

1.0.0.0

Podio authentication including rate-limit controlling

  Sources   Download

The Requires

 

by Avatar rijosh