1. Go to this page and download the library: Download lucinda/oauth2-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/ */
if (empty($_GET["code"])) {
// redirects to vendor in order to get authorization code
$redirectURL = $driver->getAuthorizationCodeEndpoint();
header("Location: ".$redirectURL);
exit();
} else {
// exchanges authorization code with an access token
$accessTokenResponse = $driver->getAccessToken($_GET["code"]);
// save $accessTokenResponse to storage
// save $driver to storage
}
// loads $accessTokenResponse from storage
if ($accessTokenResponse->getExpiresIn() && $accessTokenResponse->getExpiresIn()>time()) {
$accessTokenResponse = $driver->refreshAccessToken($accessTokenResponse->getRefreshToken());
// save $accessTokenResponse to storage
}