PHP code example of werk365 / laraveloauthclient

1. Go to this page and download the library: Download werk365/laraveloauthclient 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/ */

    

werk365 / laraveloauthclient example snippets


use Werk365\LaravelOAuthClient\LaravelOAuthClient as OAuth;

// ...

$oauth = new OAuth("vendorname");

// Returns array defined in config
$response = $oauth->getToken($code);

//Returns array defined in config
$response = $oauth->getInfo($accesstoken);

//Returns array defined in config
$response = $oauth->refreshToken($refreshtoken);



return [
    'vendor1' => [
        'client_id' => '1234',
        'client_secret' => '12345',
        'redirect_uri' => 'https://www.example.com/oauth2/vendor1',
        'token' => [
            'url' => 'https://login.vendor.example.com/oauth2/token',
            'method' => 'POST',
            'grant_type' => 'authorization_code',
            'fields' => [
                'access_token' => 'access_token',
                'expires_in' => 'expires_in',
                'refresh_token' => 'refresh_token',
            ],
            'auth' => 'body',
        ],
        'refresh' => [
            'url' => 'https://login.vendor.example.com/oauth2/token',
            'method' => 'POST',
            'grant_type' => 'authorization_code',
            'fields' => "*",
            'auth' => 'body',
        ],
        'info' => [
            'url' => 'https://login.vendor.example.com/oauth2/metadata',
            'method' => 'GET',
            'fields' => [
                'metadata1',
                'metadata2',
            ],
        ],
    ],
    'vendor2' => ['...'],
];

bash
$ php artisan vendor:publish --provider="Werk365\LaravelOAuthClient\LaravelOAuthClientServiceProvider"