Restores access token.
@return OAuthToken auth token.
964332
protected function restoreAccessToken()
    {
        $token = $this->getState('token');
        if (is_object($token)) {
            /* @var $token OAuthToken */
            if ($token->getIsExpired() && $this->autoRefreshAccessToken) {
                $token = $this->refreshAccessToken($token);
            }
        }
        return $token;
    }
1322161
public function getAccessToken()
    {
        if (! $this->accessTokenEntity instanceof AccessTokenEntity) {
            $this->accessTokenEntity = $this->server->getAccessTokenStorage()->get($this->accessTokenId);
        }

        return $this->accessTokenEntity;
    }
1049488
public function getAccessToken() {
		$time = time();
		if(empty($this->app->access_token) || $this->app->access_token_expired_at < $time) {
			$data = $this->getData('/cgi-bin/token', [
				'grant_type' => 'client_credential',
				'appid' => $this->app->appid,
				'secret' => $this->app->secret,
			]);
			if(isset($data['access_token']) && isset($data['expires_in'])) {
				$this->app->access_token = $data['access_token'];
				$this->app->access_token_expired_at = $time + $data['expires_in'];
				$this->app->save();
			}
		}

		return $this->app->access_token;
	}
335784
public static function getAccessToken()
    {
        if (static::$token) {
            return static::$token;
        }
        $response = static::$httpClient->post(static::GET_TOKEN_ENDPOINT, [
            'form_params' => [
                'client_id' => static::$apiContext->getClientId(),
                'client_secret' => static::$apiContext->getClientSecret(),
                'grant_type' => 'silent',
                'kdt_id' => static::$apiContext->getKdtId(),
            ]
        ]);
        $json = \GuzzleHttp\json_decode((string) $response->getBody(), true);
        $expiresAt = new \DateTime($json['expires_in'] . ' seconds');

        return static::$token = new Token($json['access_token'], $expiresAt);
    }
74964
public function getToken()
    {
        if (!$this->token) {
            $session = new Session('Auth');
            if (!$session->token) {
                $session->token = uniqid();
            }
            $this->token = $session->token;
        }
        return $this->token;
    }
255052
public function getAccessToken()
    {
        // get token from cache file
        $result = $this->readAccessToken();
        if ('' != $result) {
            return $result;
        }

        // get token from we chat api
        $data   = $this->getAccessTokenFromWeChat();
        // save token to cache data
        $this->saveAccessToken($data['token'], $data['expire']);

        return $data['token'];
    }
382829
public function getAccessToken(){
		// get stored AccessToken
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken !== null && $accessToken->isExpired()){
			// delete AccessToken if expired
			$this->getConfig()->getStorage()->deleteAccessToken();
			$accessToken = null;
		}
		if($accessToken !== null){
			// return AccessToken if stored and not expired
			return $accessToken;
		}
		// no AccessToken stored
		
		// get RefreshToken. May result in valid AccessToken
		$refreshToken = $this->getRefreshToken();
		if(null === $refreshToken){
			// no RefreshToken provided. need to continue polling.
			return null;
		}
		// check if AccessToken was set
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken){
			return $accessToken;
		}
		// otherwise fetch new AccessToken with the RefreshToken
		return $this->getAccessTokenWithRefreshToken($refreshToken);
	}
1326747
public function getAccessToken()
    {
        if ($this->accessToken) {
            return $this->accessToken;
        }

        $cacheKey = $this->getAccessTokenCacheKey();
        $credential = $this->cache->get($cacheKey);

        if (!$credential || $credential['expireTime'] - time() < 60) {
            if (!$http = $this->getToken()) {
                return false;
            }

            $this->accessToken = $http['access_token'];
            $this->cache->set($cacheKey, [
                'accessToken' => $http['access_token'],
                'expireTime' => time() + $http['expires_in'],
            ]);
        } else {
            $this->accessToken = $credential['accessToken'];
        }

        return $this->accessToken;
    }
235758
public function refreshAccessToken()
	{
		$newToken = $this->http->requestAccessToken();
		if (!is_null($newToken))
		{
			$this->config->setAccessToken($newToken);
			$this->http = new Request($this->guzzle, $this->config, $this->climate);
			if ($this->config->shouldStoreToken())
			{
				file_put_contents(Helper::getStoragePath($this->config->getStorageTokenFilename()), $newToken);
			}
		}

		return $newToken;
	}
167253
public function accessTokens()
    {
        if (is_null($this->accessTokenRequests)) {
            $this->accessTokenRequests = new AccessTokenRequest($this->client);
        }

        return $this->accessTokenRequests;
    }
1009776
public function refreshToken() {
        if (!$this->delete()) {
            return false;
        }
        $this->isNewRecord = true;
        $this->refresh_token = $this->generateAccessToken();
        $this->expires = Time::timestamp(time() + 3600 * 24 * 365);
        $this->save();
        return OAuthAccessTokenModel::createToken($this->client_id, $this->user_id);
    }
89734
protected function acquireAccessToken()
    {
        $accessToken = null;

        if ($this->refreshTokenGrantType) {
            // Get an access token using the stored refresh token.
            if ($this->refreshToken) {
                $this->refreshTokenGrantType->setRefreshToken($this->refreshToken->getToken());
            }
            if ($this->refreshTokenGrantType->hasRefreshToken()) {
                $accessToken = $this->refreshTokenGrantType->getToken();
            }
        }

        if (!$accessToken && $this->grantType) {
            // Get a new access token.
            $accessToken = $this->grantType->getToken();
        }

        return $accessToken ?: null;
    }
513500
public function getAccessTokenByAuth()
    {
        if ($this->accessToken) {
            return $this->accessToken;
        }

        if ($this->authed) {
            $this->accessToken = $this->wechatComponentApi->getAuthorizerAccessToken(
                $this->getAppId(),
                $this->getRefreshToken()
            );
        } else {
            $this->getAccessToken();
        }

        return $this->accessToken;
    }
285331
public function refreshToken(): AccessToken
    {
        if (empty($this->refreshTokenMiddlewares)) {
            throw new NoMiddlewareSetException('No refresh token middleware present.');
        }
        $token = $this->token;
        foreach ($this->refreshTokenMiddlewares as $middleware) {
            $token = $middleware->handleRefreshToken($token, $this->lastRequest->tries());
        }

        return $this->token = $token;
    }
43505
public function getAccessToken() 
    {
        $result = null;
        $options = $this->config->getAccessTokenConfiguration();
        $token = $this->getResponse('/oauth/token', $options);
        if (isset($token['access_token'])) {
            $this->config->setBearer($token['access_token']);
        }else {
            echo 'ERROR: no access token in API response';
        }
    }
109455
public function getAccessToken()
    {
        //Check if AccessToken needs to be refreshed
        $now = time();
        $time = time();
        $difference = $this->access_token_expire - $time;
        if ($difference < strtotime('15 minutes', 0)) {
            $this->refreshAccessToken();
        }

        return $this->access_token;
    }
561245
public function getAccessToken() {
    $token = self::$auth->getAccessToken();
    return (null == $token || 'null' == $token) ? null : $token;
  }