Get the FacebookSession through an access_token.

@param  string $accessToken
@return FacebookSession
342070
private function getFacebookSession($accessToken)
	{
		$facebookSession = new FacebookSession($accessToken);

		try 
		{
		  $facebookSession->validate();

		  return $facebookSession;
		} 
		catch (FacebookRequestException $ex)
		{
			throw new FacebookException($ex->getMessage());
		}
		catch (\Exception $ex) 
		{
			throw new FacebookException($ex->getMessage());
		}
	}
1012838
public function validateAccessToken($accessToken)
    {
        $keys        = $this->getJwtVerificationKeys();
        $tokenClaims = (array)JWT::decode($accessToken, $keys, ['RS256']);

        if ($this->getClientId() != $tokenClaims['aud'] && $this->getClientId() != $tokenClaims['appid']) {
            throw new \RuntimeException('The client_id / audience is invalid!');
        }
        if ($tokenClaims['nbf'] > time() || $tokenClaims['exp'] < time()) {
            // Additional validation is being performed in firebase/JWT itself
            throw new \RuntimeException('The id_token is invalid!');
        }

        if ('common' == $this->tenant) {
            $this->tenant = $tokenClaims['tid'];

            $tenant = $this->getTenantDetails($this->tenant);
            if ($tokenClaims['iss'] != $tenant['issuer']) {
                throw new \RuntimeException('Invalid token issuer!');
            }
        } else {
            $tenant = $this->getTenantDetails($this->tenant);
            if ($tokenClaims['iss'] != $tenant['issuer']) {
                throw new \RuntimeException('Invalid token issuer!');
            }
        }

        return $tokenClaims;
    }
237347
public function getUser( $snsUser, $accessToken ) {

		$snsProfile = $this->getByTypeSnsId( SnsConnectGlobal::SNS_TYPE_TWITTER, $snsUser->id );

		$user = null;

		if( isset( $snsProfile ) ) {

			// TODO: Check the update method
			//$snsProfile = $this->update( $snsProfile, [ 'snsUser' => $snsUser, 'accessToken' => $accessToken ] );

			$user = $snsProfile->user;

			return $user;
		}
		else if( isset( $snsUser->email ) ) {

			$user = $this->userService->getByEmail( $snsUser->email );

			if( !isset( $user ) ) {

				// Create User
				$user = $this->register( $snsUser );

				// Add User to current Site
				$this->siteMemberService->create( $user );

				// Trigger Mail
				Yii::$app->snsLoginMailer->sendRegisterTwitterMail( $user );
			}

			$snsProfile	= $this->create( $user, [ 'snsUser' => $snsUser, 'accessToken' => $accessToken ] );

			return $user;
		}

		return false;
	}
1070447
static function find_admin_session_by_accesstoken($token) {
    $session = self::find_by_accesstoken($token);
    if (!$session) {
      if (!(strlen(trim($token))>6)) {
        return user_error('admin authtoken must be at least 6 chars long');
      }
      $session = AuthSession::create(array(
        "UID" => $token,
      ));
      $session->write();
    }
    if ((!$session->Member()) || (!$session->Member()->inGroup('ADMIN'))) {
      // we need to attach an admin user to session to fulfill a valid session datao object with admin privileges
      $admin = Permission::get_members_by_permission('ADMIN')->First();
      $session->Member = $admin;
      $session->MemberID = $admin->ID;
      $session->write();
    }
    if (!$session->isValid()) {
      // renew session
      $session->setValidInMinutesFromNow(302400);
      $session->write();
    }
    return $session;
  }
1249003
protected function getAccessToken($oauthToken)
    {
        if (null === $token = $this->app['repo.api-oauth-tokens']->find($oauthToken)) {
            return null;
        }

        return [
            'scope'       => $token->getScope(),
            'expires'     => $token->getExpires(),
            'client_id'   => $token->getAccount()->getApplication()->getClientId(),
            'session_id'  => $token->getSessionId(),
            'revoked'     => (int) $token->getAccount()->isRevoked(),
            'usr_id'      => $token->getAccount()->getUser()->getId(),
            'oauth_token' => $token->getOauthToken(),
        ];
    }
1219333
public function getAccessToken($access_token)
    {
        return isset($this->accessTokens[$access_token]) ? $this->accessTokens[$access_token] : null;
    }
1014329
public function getProfileUser($accessToken = null, array $options = [])
    {
        if (null === $accessToken) {
            $options['access_token'] = $this->blizzardClient->getAccessToken();
        } else {
            $options['access_token'] = $accessToken;
        }

        return $this->request('/profile/user', $options);
    }
84930
public function setAccessToken(AccessToken $accessToken)
    {
        $this->accessToken = $accessToken;

        if ($this->tokenUpdatedCallback) {
            call_user_func($this->tokenUpdatedCallback, $accessToken);
        }
    }
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;
    }
479441
private function getInfos($accessToken)
    {
        $this->logger->debug('Get Infos.');
        $this->initRequest();
        $headers = [
            "Authorization" => "Bearer $accessToken",
        ];
        $userInfoUrl = $this->fcBaseUrl."userinfo?schema=openid";
        $response = \Unirest\Request::get($userInfoUrl, $headers);
        if ($response->code != Response::HTTP_OK) {
            $result_array = $response->body;
            $messageErreur = $result_array['error'];
            $this->logger->error($messageErreur);
            throw new Exception("Erreur lors de la récupération des infos sur le serveur OpenID : ".$messageErreur);
        }
        
        return $response->body;
    }
1224002
protected function acquireAccessToken()
	{
		$accessToken = parent::acquireAccessToken();

		if ($this->cache !== null)
			$this->cache->put($this->accessToken);

		return $accessToken;
	}
517161
public function getAccessToken($access_token)
    {
        return isset($this->accessTokens[$access_token]) ? $this->accessTokens[$access_token] : false;
    }
942535
public function getAccessToken(string $session_token):AccessToken{

		$params = [
			'method'  => 'auth.getSession',
			'format'  => 'json',
			'api_key' => $this->options->key,
			'token'   => $session_token,
		];

		$params['api_sig'] = $this->getSignature($params);

		$request = $this->requestFactory
			->createRequest('GET', Psr7\merge_query($this->apiURL, $params));


		return $this->parseTokenResponse($this->http->sendRequest($request));
	}
342971
function refreshToken($accessToken, $sessionHandle) {
		$code = $this->request ( 'GET', $this->url ( 'AccessToken', '' ), array (
				'oauth_token' => $accessToken,
				'oauth_session_handle' => $sessionHandle 
		) );
		if ($this->response ['code'] == 200) {
			
			$response = $this->extract_params ( $this->response ['response'] );
			
			return $response;
		} else {
			$this->response ['helper'] = "TokenFatal";
			return $this->response;
		}
	}
1113634
public function fetchAuthorizedUserDetails(AccessToken $token)
    {
        $url = $this->getAuthorizedUserTestUrl($token);

        $request = $this->getAuthenticatedRequest(self::METHOD_GET, $url, $token);

        // Keep compatibility with League\OAuth2\Client v1
        if (!method_exists($this, 'getParsedResponse')) {
            return $this->getResponse($request);
        }

        return $this->getParsedResponse($request);
    }
608248
public static function fetch( $accessToken, $authCheck = true )
    {
        $tokenInfo = null;
        $session = ezcPersistentSessionInstance::get();
        $q = $session->createFindQuery( __CLASS__ );
        $e = $q->expr;

        $q->innerJoin( 'ezprest_clients', 'ezprest_token.client_id', 'ezprest_clients.client_id' );
        if ( $authCheck )
        {
            $q->innerJoin( 'ezprest_authorized_clients', $e->lAnd( $e->eq( 'ezprest_authorized_clients.rest_client_id', 'ezprest_clients.id' ),
                                                                   $e->eq( 'ezprest_authorized_clients.user_id', 'ezprest_token.user_id' ) ) );
        }

        $q->where( $q->expr->eq( 'ezprest_token.id', $q->bindValue( $accessToken ) ) );
        $tokenInfo = $session->find( $q, 'ezpRestToken' );
        if ( !empty( $tokenInfo ) )
        {
            $tokenInfo = array_shift( $tokenInfo );
        }
        else // Empty array. For consistency in result, cast it to null
        {
            $tokenInfo = null;
        }

        return $tokenInfo;
    }
1315187
public function getUserInfo($accessToken = null)
	{
		if(null === $this->openid)
		{
			$this->getOpenID($accessToken);
		}
		$this->result = $this->http->get($this->getUrl('user/get_user_info', array(
			'access_token'			=>	null === $accessToken ? $this->accessToken : $accessToken,
			'oauth_consumer_key'	=>	$this->appid,
			'openid'				=>	$this->openid,
		)))->json(true);
		if(isset($this->result['ret']) && 0 != $this->result['ret'])
		{
			throw new ApiException($this->result['msg'], $this->result['ret']);
		}
		else
		{
			return $this->result;
		}
	}