PHP code example of contactduty / oauth-contact-duty
1. Go to this page and download the library: Download contactduty/oauth-contact-duty 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/ */
contactduty / oauth-contact-duty example snippets
try {
$provider = new ContactDuty\OAuth2\Client([
'clientId' => $clientId,
'clientSecret' => $clientSecret,
'redirectUri' => $redirectUri
]);
$accessToken = $provider->getAccessToken('client_credentials');
echo 'Access Token: ' . $accessToken->getToken() . "<br>";
echo 'Expired in: ' . $accessToken->getExpires() . "<br>";
echo 'Already expired? -> ' . ($accessToken->hasExpired() ? 'expired' : 'not expired') . "<br>";
} catch (League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
// Failed to get the access token
die($e->getMessage());
}