public function testRequest() { require __DIR__ . '/cfgs/ads_config.php'; if (isset($proxyHost) && isset($proxyPort)) { RestfulEnvironment::setProxy($proxyHost, $proxyPort); } if (isset($allowAllCerts)) { RestfulEnvironment::setAcceptAllCerts($allowAllCerts); } $tokenSrvc = new OAuthTokenService($FQDN, $api_key, $secret_key); $token = $tokenSrvc->getToken('ADS'); $this->assertTrue($token->getAccessToken() != ''); $token = $tokenSrvc->refreshToken($token); $this->assertTrue($token->getAccessToken() != ''); }
public function refreshConsentToken($old_token, $scope) { // Create service for requesting an OAuth token $osrvc = new OAuthTokenService($this->base_url, $this->client_id, $this->client_secret); // Refresh Consent token if (DEBUG) { Debug::init(); $a = $old_token->getRefreshToken(); Debug::write("Old Refresh token: {$a}.\n"); Debug::end(); } $token = $osrvc->refreshToken($old_token); if (DEBUG) { Debug::init(); $a = $token->getAccessToken(); $b = $token->getTokenExpiry(); $c = $token->getRefreshToken(); Debug::write("New Token: {$a}. New Expiry: {$b}. New Refresh Token: {$c}.\n"); Debug::end(); } // Parse the consent_tokens array and update each taken that matches old_token $consent_tokens = isset($_SESSION['consent_tokens']) ? $_SESSION['consent_tokens'] : ''; foreach ($consent_tokens as $key => $value) { if ($_SESSION['consent_tokens'][$key] == $old_token->getAccessToken()) { $_SESSION['consent_tokens'][$key] = $token->getAccessToken(); $_SESSION['consent_refresh_tokens'][$key] = $token->getRefreshToken(); $_SESSION['consent_expires_at'][$key] = $token->getTokenExpiry(); } } return $token; }