PHP code example of waywake / auth-client

1. Go to this page and download the library: Download waywake/auth-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

waywake / auth-client example snippets


PdAuth\PdAuthServiceProvider::class

use PdAuth\Controller;

class UserController
{
    use Controller;

    public function __construct()
    {
        $this->auth('erp');
    }

    public function me()
    {
        return $this->user;
    }
}

class OrderController
{
    public const Privileges = [
        'index' => ['admin', 'sales'],
        'show' => '*',
    ];
}

$auth = app('pd.auth')->choose('erp');

$loginUrl = $auth->connect('https://app.example.com/callback');
$token = $auth->getAccessToken($code);
$user = $auth->getUserInfo($token['access_token']);
$auth->logout($token['access_token']);

$auth = app('pd.auth')->choose(null, '100009');
bash
php artisan vendor:publish --tag=pdauth