获取 AccessToken 实例
@return OAuth2AccessToken
@throws Exception
355750
public function getAccessToken()
    {
        if (is_null($this->_accessToken)) {
            if (empty($this->access_token)) {
                $this->errorServer(Yii::t('yuncms', 'The request is missing "access_token" parameter'));
            }
            if (!$this->_accessToken = OAuth2AccessToken::findOne(['access_token' => $this->access_token])) {
                $this->errorServer(Yii::t('yuncms', 'The Access Token is invalid'));
            }
        }
        return $this->_accessToken;
    }
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;
  }
562247
public String createOAuth2AccessToken(DbxOAuth1AccessToken token)
        throws DbxException
    {
        if (token == null) throw new IllegalArgumentException("'token' can't be null");
        return DbxRequestUtil.doPostNoAuth(
            requestConfig,
            DbxClientV1.USER_AGENT_ID,
            appInfo.getHost().getApi(),
            "1/oauth2/token_from_oauth1",
            null,
            getHeaders(token),
            new DbxRequestUtil.ResponseHandler<String>() {
                @Override
                public String handle(HttpRequestor.Response response) throws DbxException {
                    if (response.getStatusCode() != 200) throw DbxRequestUtil.unexpectedStatus(response);
                    return DbxRequestUtil.readJsonFromResponse(ResponseReader, response);
                }
            }
        );
    }
990171
public function acquireAccessToken()
  {
    $request = new Request(
        self::METADATA_AUTH_URL,
        'GET',
        array(
          'Metadata-Flavor' => 'Google'
        )
    );
    $request->disableGzip();
    $response = $this->client->getIo()->makeRequest($request);

    if ($response->getResponseHttpCode() == 200) {
      $this->setAccessToken($response->getResponseBody());
      $this->token['created'] = time();
      return $this->getAccessToken();
    } else {
      throw new Exception(
          sprintf(
              "Error fetching service account access token, message: '%s'",
              $response->getResponseBody()
          ),
          $response->getResponseHttpCode()
      );
    }
  }
1115971
protected function getAccessToken()
    {
        $response = $this->httpClient
            ->post(
                self::ENDPOINT_ACCESS_TOKEN,
                array(
                    'grant_type'    => 'client_credentials',
                    'client_id'     => $this->config['client_id'],
                    'client_secret' => $this->config['client_secret'],
                    'scope'         => implode(',', $this->config['scopes'])
                )
            )
        ;

        $data = json_decode($response->getContent(), true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            $ex = new HttpResponseException('[access_token] Invalid JSON: '. json_last_error_msg());
            $ex
                ->setResponse($this->httpClient->getLastResponse())
                ->setRequest($this->httpClient->getLastRequest())
            ;

            throw $ex;
        }

        if (false === array_key_exists('access_token', $data)) {
            throw new HttpResponseException('access_token is missing from response. '. $response->getContent());
        }

        return $data;
    }
579981
protected function requestAccessToken()
    {
        $result = $this->httpGet(self::WECHAT_ACCESS_TOKEN_PREFIX, [
            'corpid' => $this->corpId,
            'corpsecret' => $this->secret
        ]);
        return isset($result['access_token']) ? $result : false;
    }
342120
private function getToken()
    {
        if (!$token = $this->storage->get('access_token')) {
            if (!$token = $this->storage->get('request_token')) {
                $token = new \stdClass();
                $token->oauth_token = null;
                $token->oauth_token_secret = null;
            }
        }
        return $token;
    }
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);
        }
    }
304126
public function getToken()
    {
        $cacheKey = sprintf($this->cacheKey, $this->authorizer_appid);

        $this->token = Cache::get($cacheKey, function () use ($cacheKey) {
            $params = array(
                'component_appid'          => Config::get('wechat.componentAppId'),
                'authorizer_appid'         => $this->authorizer_appid,
                'authorizer_refresh_token' => $this->authorizer_refresh_token,
            );

            $http = new ComponentHttp(new ComponentAccessToken());
            $response = $http->jsonPost(self::API_AUTHORIZER_TOKEN, $params);

            // 设置token
            $token = $response['authorizer_access_token'];

            // 把token缓存起来
            $expiresAt = Carbon::now()->addSeconds($response['expires_in']);
            Cache::put($cacheKey, $token, $expiresAt);

            return $token;
        });

        return $this->token;
    }
781901
private function get_access_token() {
        global $SESSION;
        if (isset($SESSION->{self::SESSIONKEY}) && $SESSION->{self::SESSIONKEY}) {
            $this->client->setAccessToken($SESSION->{self::SESSIONKEY});
            return $SESSION->{self::SESSIONKEY};
        }
        return null;
    }
920028
public function getAccessToken()
    {
        return $this->requestHandler->sendRequestAsync('POST', 'api/v4/oauth/access_token/')->then(
            function ($tokenValues) {
                parse_str($tokenValues, $tokenArray);
                $token = $tokenArray['oauth_token'];
                $tokenSecret = $tokenArray['oauth_token_secret'];
                $this->requestHandler->setAccessTokenCredentials($token, $tokenSecret);
                return $tokenArray;
            }
        );
    }
205376
protected function generateAccessToken()
    {
        $tokenLen = 40;
        if (file_exists('/dev/urandom')) { // Get 100 bytes of random data
            $randomData = file_get_contents('/dev/urandom', false, null, 0, 100) . uniqid(mt_rand(), true);
        } else {
            $randomData = mt_rand() . mt_rand() . mt_rand() . mt_rand() . microtime(true) . uniqid(mt_rand(), true);
        }
        return substr(hash('sha512', $randomData), 0, $tokenLen);
    }
1069547
public function getAccessToken() {
        if (!empty($this->accessToken)) {
            return $this->accessToken;
        }
        $accessToken = $this->sessionStorage->read('access_token');
        if (!empty($accessToken)) {
            $this->accessToken = $accssToken;
            return $this->accessToken;
        }

        $this->exchangeToken();

        return $this->accessToken;
    }
58521
public function getAccessToken(): AccessToken
	{
		$helper = $this->facebook->getRedirectLoginHelper();

		try {
			// Get accessToken from $_GET
			$accessToken = $helper->getAccessToken();

			// Failed to get accessToken
			if (!isset($accessToken)) {
				if ($helper->getError() !== null) {
					throw new FacebookLoginException($helper->getError());
				} else {
					throw new FacebookLoginException('Facebook: Bad request.');
				}
			}

			$accessToken = $this->getLongLifeValidatedToken($accessToken);
		} catch (FacebookResponseException | FacebookSDKException $e) {
			throw new FacebookLoginException($e->getMessage());
		}

		return $accessToken;
	}
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;
    }
643057
public function getAccessToken() {
    $session = $this->getSession();
    // either user session signed, or app signed
    if ($session) {
      return $session['access_token'];
    } else {
      return $this->getAppId() .'|'. $this->getApiSecret();
    }
  }