PHP code example of jwilsson / auto-refresh-oauth2-token-plugin
1. Go to this page and download the library: Download jwilsson/auto-refresh-oauth2-token-plugin 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/ */
jwilsson / auto-refresh-oauth2-token-plugin example snippets
use Http\Client\Common\PluginClient;
use JWilsson\AutoRefreshOAuth2TokenPlugin;
$autoRefreshOAuth2TokenPlugin = new AutoRefreshOAuth2TokenPlugin(
$token,
$refreshTokenGrant,
$options, // Options for the plugin, see below
$refreshTokenOptions // Additional options to pass to RefreshToken::requestAccessToken()
);
$pluginClient = new PluginClient(
$myHttpClient,
[$autoRefreshOAuth2TokenPlugin]
);
$response = $pluginClient->sendRequest($myRequest);
// Remember to grab the token object after each call, it might have been updated with new information
$refreshedToken = $autoRefreshOAuth2TokenPlugin->getToken();