Get the access token from the token response body.

@param \Psr\Http\Message\StreamInterface|array $body

@return \Overtrue\Socialite\AccessTokenInterface
171407
protected function parseAccessToken($body)
    {
        if (!is_array($body)) {
            $body = json_decode($body, true);
        }

        if (empty($body['access_token'])) {
            throw new AuthorizeFailedException('Authorize Failed: '.json_encode($body, JSON_UNESCAPED_UNICODE), $body);
        }

        return new AccessToken($body);
    }
459078
protected function findAccessToken(array $response)
    {
        return $this->tokens->find(
            $this->jwt->parse($response['access_token'])->getClaim('jti')
        );
    }
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);
    }
450726
public function getAccessToken(string $service):AccessToken{

		if($this->hasAccessToken($service)){
			return $this->tokens[$service];
		}

		throw new OAuthStorageException('token not found');
	}
973691
public function chargeAuthorization($body)
    {
        $request = $this->paystackHttpClient->post(
            Resource::CHARGE_AUTHORIZATION,
            [
                'body'  => is_array($body) ? $this->toJson($body) : $body,
            ]
        );

        return $this->processResourceRequestResponse($request);
    }
1206685
public function getByAccessToken(AccessTokenEntity $accessToken)
    {
        $result = $this->getConnection()->table('oauth_sessions')
                ->select('oauth_sessions.*')
                ->join('oauth_access_tokens', 'oauth_sessions.id', '=', 'oauth_access_tokens.session_id')
                ->where('oauth_access_tokens.id', $accessToken->getId())
                ->first();

        if (is_null($result)) {
            return;
        }

        return (new SessionEntity($this->getServer()))
               ->setId($result->id)
               ->setOwner($result->owner_type, $result->owner_id);
    }
623038
public function fetch_access_token(&$request) {/*{{{*/
    $this->get_version($request);

    $consumer = $this->get_consumer($request);

    // requires authorized request token
    $token = $this->get_token($request, $consumer, "request");


    $this->check_signature($request, $consumer, $token);

    $new_token = $this->data_store->new_access_token($token, $consumer);

    return $new_token;
  }
95328
public static function signInWithAccessToken( $accesstoken )
	{
		$username = self::getUsernameFromAccessToken( $accesstoken );

		if ( is_null( $username ) ) return false;

		$ip = self::getClientIp();
		$ua = ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) ? $_SERVER['HTTP_USER_AGENT'] : '';
		$ts = date("U");
		$cu = get_current_url( true );

		self::$api_session = array( 'username' => $username );

		self::$auth['users'][ $username ]['api_logincount'] = (int) @self::$auth['users'][ $username ]['api_logincount'] + 1;
		self::$auth['users'][ $username ]['api_lastlogin'] = array(
			'ip' => $ip,
			'ua' => $ua,
			'ts' => $ts
		);
		if ( ! is_null( $cu ) ) self::$auth['users'][ $username ]['api_lastlogin']['ur'] = $cu;
		self::save();

		return self::$auth['users'][ $username ];
	}
668929
public function createStream($body = null)
    {
        if ($body instanceof StreamInterface)
        {
            return $body;
        }

        if (\is_resource($body))
        {
            return Stream::createFromResource($body);
        }

        return Stream::create($body ?? '');
    }
31593
protected function getAccessTokenRequest(array $params)
    {
        $request = parent::getAccessTokenRequest($params);
        $uri = $request->getUri()
            ->withUserInfo($this->clientId, $this->clientSecret);

        return $request->withUri($uri);
    }
1052777
private function getHeaders(array $userHeaders, $body): array
    {
        $headers = [
            'X-Contentful-User-Agent' => $this->userAgentGenerator->getUserAgent(),
            'Accept' => $this->apiContentType,
            'Accept-Encoding' => 'gzip',
            'Authorization' => 'Bearer '.$this->accessToken,
        ];

        if ($body) {
            $headers['Content-Type'] = $this->apiContentType;
        }

        return \array_merge($headers, $userHeaders);
    }
557423
protected function buildValidationReturn(array $body)
    {
        if (isset($body['user'])) {
            $body['user'] = new User($body['user']);
        }

        $body['application'] = new Application($body['application']);
        $body['expire_at'] = new \DateTime($body['expire_at']);

        return $body;
    }
884444
public function getAccessToken($refresh = false)
    {
        if ($this->_auth) {
            return $this->_auth->getToken($refresh)->access_token;
        } else {
            return null;
        }
    }
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;
	}
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;
            }
        );
    }
684493
public static function getAuthToken($object)
    {
        $context = array_merge(array('grant_type' => 'authorization_code'), (array)$object);
        $connection = new Connection();

        return $connection->post(self::$login_url . '/oauth2/token', $context);
    }
870315
protected function getResponse(array $headers, $body)
	{
		// Create the response object.
		$return = new Response;

		// Set the body for the response.
		$return->body = $body;

		// Get the response code from the first offset of the response headers.
		preg_match('/[0-9]{3}/', array_shift($headers), $matches);
		$code = $matches[0];

		if (is_numeric($code))
		{
			$return->code = (int) $code;
		}

		// No valid response code was detected.
		else
		{
			throw new \UnexpectedValueException('No HTTP response code found.');
		}

		// Add the response headers to the response object.
		foreach ($headers as $header)
		{
			$pos = strpos($header, ':');
			$return->headers[trim(substr($header, 0, $pos))] = trim(substr($header, ($pos + 1)));
		}

		return $return;
	}