Fetches a fresh access token with the given refresh token.
@param string $refreshToken
@return void
500760
public function refreshToken($refreshToken)
  {
    $this->refreshTokenRequest(
        array(
          'client_id' => $this->client->getClassConfig($this, 'client_id'),
          'client_secret' => $this->client->getClassConfig($this, 'client_secret'),
          'refresh_token' => $refreshToken,
          'grant_type' => 'refresh_token'
        )
    );
  }
301448
public function getAuthorizerAccessToken($appId, $refreshToken)
    {
        $cacheKey = $this->getAuthorizerAccessTokenCacheKey($appId);
        $credential = $this->cache->get($cacheKey);
        if (!$credential || $credential['expireTime'] - time() < 60) {
            $ret = $this->authorizerToken($appId, $refreshToken);
            if ($ret['code'] !== 1) {
                return $ret;
            } else {
                $credential = [
                    'accessToken' => $ret['authorizer_access_token'],
                    'expireTime' => time() + $ret['expires_in'],
                    'refreshToken' => $ret['authorizer_refresh_token'],
                ];
                $this->cache->set($cacheKey, $credential);
            }
        }

        return $credential['accessToken'];
    }
655806
public function refreshToken($forceRefresh = false)
    {
        if (property_exists($this, "sdl") && $this->sdl == 0) {
            parent::__construct($this->xmlLoc, array('trace'=>1, 'exceptions'=>0));
        }
        try {
            $currentTime = new DateTime();
            if (is_null($this->getAuthTokenExpiration($this->tenantKey))) {
                $timeDiff = 0;
            } else {
                $timeDiff = $currentTime->diff($this->getAuthTokenExpiration($this->tenantKey))->format('%i');
                $timeDiff = $timeDiff  + (60 * $currentTime->diff($this->getAuthTokenExpiration($this->tenantKey))->format('%H'));
            }
            if (is_null($this->getAuthToken($this->tenantKey)) || ($timeDiff < 5) || $forceRefresh) {
                $url = $this->tenantKey == null
                        ? $this->baseAuthUrl."/v1/requestToken?legacy=1"
                        : $this->baseUrl."/provisioning/v1/tenants/{$this->tenantKey}/requestToken?legacy=1";

                $jsonRequest = new stdClass();
                $jsonRequest->clientId = $this->clientId;
                $jsonRequest->clientSecret = $this->clientSecret;
                $jsonRequest->accessType = "offline";
                if (!is_null($this->getRefreshToken($this->tenantKey))) {
                    $jsonRequest->refreshToken = $this->getRefreshToken($this->tenantKey);
                }
                $authResponse = ET_Util::restPost($url, json_encode($jsonRequest), $this);
                $authObject = json_decode($authResponse->body);
                //echo "auth:  \n";
                //print_r($authResponse);

                if ($authResponse && property_exists($authObject, "accessToken")) {
                    $dv = new DateInterval('PT'.$authObject->expiresIn.'S');
                    $newexpTime = new DateTime();
                    $this->setAuthToken($this->tenantKey, $authObject->accessToken, $newexpTime->add($dv));
                    $this->setInternalAuthToken($this->tenantKey, $authObject->legacyToken);
                    if (property_exists($authObject, 'refreshToken')) {
                        $this->setRefreshToken($this->tenantKey, $authObject->refreshToken);
                    }
                } else {
                    throw new Exception('Unable to validate App Keys(ClientID/ClientSecret) provided, requestToken response:'.$authResponse->body);
                }
            }
        } catch (Exception $e) {
            throw new Exception('Unable to validate App Keys(ClientID/ClientSecret) provided.: '.$e->getMessage());
        }
    }
599479
public function refresh() {
    $grant = new RefreshTokenGrant($this->clientId, $this->clientSecret, $this->refreshToken);
    $tokens = $grant->getTokens();

    $this->accessToken = $tokens->{"access_token"};
    $this->expiresAt = Util::calculateExpiryTime($tokens->{"expires_in"});
    $this->refreshToken = $tokens->{"refresh_token"};
  }
216747
public function getRefreshToken($refresh_token)
    {
        $token = $this->getObjectByType('refresh_token_table',$refresh_token);

        return is_null($token) ? false : $token;
    }
612950
public function getTokens($refresh = false)
    {
        if (! $this->_tokens || $refresh) {
            if ($refresh) {
                $this->_firstToken = null;
            }
            $this->_tokens       = array();
            $this->_activeTokens = array();
            $tokenSelect = $this->tracker->getTokenSelect();
            $tokenSelect->andReceptionCodes()
                ->forRespondentTrack($this->_respTrackId);

            $tokenRows = $tokenSelect->fetchAll();
            $prevToken = null;
            foreach ($tokenRows as $tokenData) {

                $token = $this->tracker->getToken($tokenData);

                $this->_tokens[$token->getTokenId()] = $token;

                // While we are busy, set this
                if ($token->hasSuccesCode()) {
                    $this->_activeTokens[$token->getRoundId()] = $token;
                }

                // Link the tokens
                if ($prevToken) {
                    $prevToken->setNextToken($token);
                }
                $prevToken = $token;
            }
        }

        return $this->_tokens;
    }
241278
private function getAccessToken(): void
    {
        if ($this->tokenStorage->getRefreshToken()) {
            $body = [
                'grant_type' => 'refresh_token',
                'refresh_token' => $this->tokenStorage->getRefreshToken(),
            ];
        } else {
            $body = [
                'grant_type' => 'password',
                'username' => $this->username,
                'password' => $this->password,
            ];
            if (!empty($this->mfaToken)) {
                $body['mfa_token'] = $this->mfaToken;
            }
            if (!empty($this->scope)) {
                $body['scope'] = $this->scope;
            }
        }

        try {
            $response = $this->authClient()->post('', http_build_query($body), ['Content-Type' => 'application/x-www-form-urlencoded']);
            $this->tokenStorage->saveToken(json_decode((string) $response->getBody(), true));
        } catch (OauthRefreshTokenExpiredException $e) {
            // Clear data in token storage because refresh token has expired.
            $this->tokenStorage->removeToken();
            // Try to automatically get a new access token by sending client
            // id and secret.
            $this->getAccessToken();
        } catch (Exception $e) {
            throw new OauthAuthenticationException($e->getMessage(), $e->getCode(), $e);
        }
    }
1333971
private void refreshAccessToken() {
    final Long expiresIn = credential.getExpiresInSeconds();

    // trigger refresh if token is about to expire
    String accessToken = credential.getAccessToken();
    if (accessToken == null || expiresIn != null && expiresIn <= 60) {
      try {
        credential.refreshToken();
        accessToken = credential.getAccessToken();
      } catch (final IOException e) {
        log.error("Failed to fetch access token", e);
      }
    }
    if (accessToken != null) {
      this.accessToken = accessToken;
    }
  }
1267727
public function getRefreshToken($refresh_token)
    {
        $sql   = sprintf('SELECT * from %s where refresh_token = :refresh_token', $this->config['refresh_token_table']);
        $token = $this->fetch($sql, compact('refresh_token'));
        if ($token) {
            // convert expires to epoch time
            $token['expires'] = strtotime($token['expires']);
        }

        return $token;
    }
1368047
protected function getAccessTokenWithRefreshToken(RefreshToken $refreshToken){
		// Send post request to authentication service
		$params = array(
			'client_id' => $this->getConfig()->getClientId(),
			'refresh_token' => $refreshToken->getRefreshToken(),
			'grant_type' => 'refresh_token',
		);
		$response = $this->sendPostRequest("oauth2waitress/oauth2.svc/token", $params);
		$output = $response['output'];
		$httpcode = $response['code'];
		
		switch($httpcode){
			case "200" : 
				$responseObject = json_decode($output);
				if(isset($responseObject->error)){
					// an error occured, the RefreshToken is most likely invalid
					// delete RefreshToken to retrieve new one on next request
					$this->getConfig()->getStorage()->deleteRefreshToken();
					return null;
				}
				// create access token and save it
				$accessToken = new AccessToken(new DateTime(), $responseObject->access_token, $responseObject->token_type, $responseObject->expires_in);
				$this->getConfig()->getStorage()->saveAccessToken($accessToken);
				return $accessToken;
		}
		return null;
	}
624217
public function refresh(Token $token)
    {
        $payload = $this->setRefreshFlow()->decode($token);

        if ($this->blacklistEnabled) {
            // invalidate old token
            $this->blacklist->add($payload);
        }

        // return the new token
        return $this->encode(
            $this->payloadFactory->make([
                'sub' => $payload['sub'],
                'iat' => $payload['iat'],
            ])
        );
    }
1256532
public function updateRefreshToken(): void
    {

        tap($this->token, function ($token) {

            // If no API call was made, the client would never have
            // been instantiated and auth information never updated.
            if (is_null($this->client) || $this->public_call)
                return;

            $last_auth = $this->client->getAuthentication();

            $token->token = $last_auth->access_token ?? '-';
            $token->expires_on = $last_auth->token_expires;

            $token->save();
        });
    }
78046
public function refreshToken($accessToken = null)
    {
        $accessToken = $accessToken ?: $this->accessToken;
        $this->accessToken = $this->provider->getAccessToken('refresh_token', [
            'refresh_token' => $accessToken->getRefreshToken()
        ]);
        return $this->accessToken;
    }
108741
protected function requestNewAccessToken()
    {
        if ($this->refreshTokenGrantType && $this->rawToken && $this->rawToken->getRefreshToken()) {
            try {
                // Get an access token using the stored refresh token.
                $rawData = $this->refreshTokenGrantType->getRawData(
                    $this->clientCredentialsSigner,
                    $this->rawToken->getRefreshToken()
                );

                $this->rawToken = $this->tokenFactory($rawData, $this->rawToken);

                return;
            } catch (BadResponseException $e) {
                // If the refresh token is invalid, then clear the entire token information.
                $this->rawToken = null;
            }
        }

        if ($this->grantType === null) {
            throw new Exception\ReauthorizationException('You must specify a grantType class to request an access token');
        }

        try {
            // Request an access token using the main grant type.
            $rawData = $this->grantType->getRawData($this->clientCredentialsSigner);

            $this->rawToken = $this->tokenFactory($rawData);
        } catch (BadResponseException $e) {
            throw new Exception\AccessTokenRequestException('Unable to request a new access token', $e);
        }
    }
879638
public function refreshToken($refreshToken)
	{
		$this->result = $this->http->get($this->getUrl('oauth2.0/token', array(
			'grant_type'	=>	'refresh_token',
			'client_id'		=>	$this->appid,
			'client_secret'	=>	$this->appSecret,
			'refresh_token'	=>	$refreshToken,
		)))->jsonp(true);
		return isset($this->result['code']) && 0 == $this->result['code'];
	}
800844
public function requestAccessTokenRefresh($refreshToken)
    {
        $params = array(
            'refresh_token' => $refreshToken,
            'grant_type' => 'refresh_token',
            'scope' => $this->_getScope()
        );

        return $this->_makeRequest($this->_tokenEndPoint, $params);
    }
278653
public function getRefreshToken($refresh_token)
    {
        $result = $this->client->getItem(array(
            "TableName"=> $this->config['refresh_token_table'],
            "Key" => array('refresh_token'   => array('S' => $refresh_token))
        ));
        if ($result->count()==0) {
            return false ;
        }
        $token = $this->dynamo2array($result);
        $token['expires'] = strtotime($token['expires']);

        return $token;
    }