PHP code example of logicly / easy-oauth-client

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

    

logicly / easy-oauth-client example snippets


use Logicly\EasyOAuthClient\Client;

// ...

$oAuthClient = new Client("providername");

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

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

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



return [
    'provider1' => [
        'client_id' => '1234',
        'client_secret' => '12345',
        'redirect_uri' => 'https://www.example.com/oauth2/provider1',
        'token' => [
            'url' => 'https://login.provider.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.provider.example.com/oauth2/token',
            'method' => 'POST',
            'grant_type' => 'authorization_code',
            'fields' => "*",
            'auth' => 'body',
        ],
        'info' => [
            'url' => 'https://login.provider.example.com/oauth2/metadata',
            'method' => 'GET',
            'fields' => [
                'metadata1',
                'metadata2',
            ],
        ],
    ],
    'provider2' => ['...'],
];

bash
$ php artisan provider:publish --provider="Logicly\EasyOAuthClient\EasyOAuthClientServiceProvider"