This retrieve the access token in store or in server

@return string the access token
19979
private function prepareAccessToken()
    {
        // if not exits data in the store
        if(!$this->store->getPersistentData('token_expires_at')){
            return $this->getAccessTokenWithClientCredentials();
         // if access token expires.
        }else if($this->store->getPersistentData('token_expires_at') < time()){
            try{
                return $this->getAccessTokenWithRefreshToken();    
            }catch(AuthenticationException $e){
                return $this->getAccessTokenWithClientCredentials();
            }
        }else{
            return $this->store->getPersistentData('access_token');
        }
    }
995467
public function getAccessToken()
    {
        // check in the session
        $existing = $this->storage->getKey('authentication');

        // is it still valid
        if ($existing && $existing->expires > time()) {
            return $existing->access_token;
        }

        // make the call to the API
        $authResponse = $this->makeAuthenticationCall();

        // save the access token result
        $this->storage->setKey('authentication', $authResponse->getRaw());

        // return the token
        return $authResponse->getRaw()->access_token;
    }
1322161
public function getAccessToken()
    {
        if (! $this->accessTokenEntity instanceof AccessTokenEntity) {
            $this->accessTokenEntity = $this->server->getAccessTokenStorage()->get($this->accessTokenId);
        }

        return $this->accessTokenEntity;
    }
993180
protected function getAuthToken()
    {
        $token = $this->request->getHeader('X_AUTHORIZATION');
        if (!$token) {
            $request = $this->getDI()->get('request');
            $token = $request->getQuery('token') ?: $request->getPost('token');
        }

        $token = trim(str_ireplace('Token:', '', $token));
        if (strlen($token) < 30) {
            throw new HTTPException('Unauthorized access blocked', 401, [
                'dev' => 'Supplied Token: ' . $token,
                'code' => '98914681681864674'
            ]);
        }
        return $token;
    }
592851
public function getTokenString()
    {
        $cacheId = $this->getCacheId();

        if ($this->cache && $data = $this->cache->fetch($cacheId)) {
            return $data['access_token'];
        }

        $response = $this->getTokenResponse();

        if ($this->cache) {
            $this->cache->save($cacheId, $response, $response['expires_in']);
        }

        return $response['access_token'];
    }
1218821
public function token() {
        $key = 'WeChatToken'.$this->get('appid');
        if (Factory::cache()->has($key)) {
            return Factory::cache()->get($key);
        }
        $args = $this->getToken()->json();
        if (!is_array($args)) {
            throw new Exception('HTTP ERROR!');
        }
        if (!array_key_exists('access_token', $args)) {
            throw new Exception(isset($args['errmsg']) ?
                $args['errmsg'] : 'GET ACCESS TOKEN ERROR!');
        }
        Factory::cache()->set($key, $args['access_token'], $args['expires_in']);
        return $args['access_token'];
    }
1143792
public function acquireAccessToken() {
    $grant = new PasswordGrant($this->clientId, $this->clientSecret, $this->username, $this->password, $this->scopes);
    $tokens = $grant->getTokens();

    $accessToken = $tokens->{"access_token"};
    $refreshToken = $tokens->{"refresh_token"};
    $expiresAt = Util::calculateExpiryTime($tokens->{"expires_in"});

    return new RefreshableAccessToken($this->clientId, $this->clientSecret, $accessToken, $expiresAt, $refreshToken);
  }
322000
protected function getToken()
  {
    return $this->getRequest()->cookies->get($this->getTokenVar(), $this->getSession()->get($this->getTokenVar()));
  }
1297746
protected function get_stored_token() {
        if ($this->system) {
            $token = access_token::get_record(['issuerid' => $this->issuer->get('id')]);
            if ($token !== false) {
                return $token->to_record();
            }
            return null;
        }

        return parent::get_stored_token();
    }
32747
protected function getOAuthToken() {
        # TODO: use session to store the token
        if ($this->client_id and $this->client_secret) {
            $response = $this->httpQuery(
                'POST', 'https://orcid.org/oauth/token',
                [
                    'Accept' => 'application/json',
                    'Content-Type' => 'application/x-www-form-urlencoded'
                ],
                http_build_query([
                  'client_id' => $this->client_id,
                  'client_secret' => $this->client_secret,
                  'scope' => '/read-public',
                  'grant_type' => 'client_credentials',
                ])
            );

            if ($response) {
                return $response->{'access_token'};
            }
        }
    }
1346460
public function getBearerToken()
	{	
		try { 

			$response = $this->client->request('POST', self::$api_base.'oauth2/token', [
			    'query' => ['grant_type' => 'client_credentials'],
			    'headers' => [
			        'Authorization' => 'Basic ' . base64_encode($this->app_key.':'.$this->app_secret),
			        'Content-Type'     => 'application/x-www-form-urlencoded;charset=UTF-8'
			    ]
			]);

 			$this->setStatusCode($response->getStatusCode());
 			$response_body = json_decode($response->getBody());
 			$this->bearer_token = $this->isBearer($response_body);

 		} catch (\Exception $e) {

			$this->setStatusCode($e->getCode());
			$this->setResponse($e->getMessage());

		}
		
 	}
48102
public function token()
    {
        try {
            $response = $this->oauthServer->respondToAccessTokenRequest($this->request, new Response());

            $this->pruneTokens();

            return $response;
        } catch (\Exception $e) {
            // Rethrow the exception
            throw $e;
        }
    }
36070
private function acquireAccessToken()
    {
        if (isset($this->accessToken) && $this->accessToken->getRefreshToken()) {
            return $this->provider->getAccessToken(new RefreshToken(), ['refresh_token' => $this->accessToken->getRefreshToken()]);
        }

        return $this->provider->getAccessToken($this->grant, $this->grantOptions);
    }
492966
public function getToken()
    {
        if (!isset($this->token)) {
            $this->token = $this->csrf->getToken();
        }

        return $this->token;
    }
1311412
public function get_access_token() {
        if (isset ($this->ll_access_token) && !is_null($this->ll_access_token)) {
            return $this->ll_access_token;
        }

        $app_client_values = array(
            'client_id' => $this->client_id,
            'client_secret' => $this->client_secret,
            'grant_type' => 'client_credentials'
        );

        $access_data = MPRestClient::post(array(
            "uri" => "/oauth/token",
            "data" => $app_client_values,
            "headers" => array(
                "content-type" => "application/x-www-form-urlencoded"
            )
        ));

        if ($access_data["status"] != 200) {
            throw new MercadoPagoException ($access_data['response']['message'], $access_data['status']);
        }

        $this->access_data = $access_data['response'];

        return $this->access_data['access_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);
	}
766344
private function getAuthToken()
    {
        // Generate a new token if current is expired or empty
        if (!$this->token || new \DateTime() > $this->tokenExpireTime) {
            $this->requestToken();
        }

        return $this->token;
    }