1. Go to this page and download the library: Download cartertech/oauth2-deputy 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/ */
cartertech / oauth2-deputy example snippets
$provider = new Cartertech\OAuth2\Client\Provider\Deputy([
'clientId' => <your_client_id>, // The client ID assigned to you by the provider
'clientSecret' => <your_client_secret>, // The client password assigned to you by the provider
'redirectUri' => 'https://example.com/callback.php,
'urlAuthorize' => 'https://once.deputy.com/my/oauth/login',
'urlAccessToken' => 'https://once.deputy.com/my/oauth/access_token'
]);
$existingAccessToken = getAccessTokenFromYourDataStore();
if ($existingAccessToken->hasExpired()) {
$newAccessToken = $provider->getAccessToken('refresh_token', [
'refresh_token' => $existingAccessToken->getRefreshToken()
]);
// Purge old access token and store new access token to your data store.
}