Skip to content

Latest commit

 

History

History
36 lines (30 loc) · 740 Bytes

File metadata and controls

36 lines (30 loc) · 740 Bytes

Transport OAuth2

OAuth2 Transport requires a third package:

composer require league/oauth2-client

Example of use:

<?php
use Cristal\ApiWrapper\Transports\OAuth2;
use Illuminate\Cache\Repository as Cache;
use Curl\Curl;
use League\OAuth2\Client\Provider\GenericProvider;

$provider = new GenericProvider([
    'clientId' => '...',
    'clientSecret' => '...',
    'urlAccessToken' => '...',
    'urlAuthorize' => '...',
    'urlResourceOwnerDetails' => '...',
]);

$transport = new OAuth2('http://...', $provider, new Curl);
$transport
    ->setCacheRepository(new Cache)
    ->setGrant('password')
    ->setOptions([
        'username' => '...',
        'password' => '...',
        'scope' => '...',
    ])
;