Overtrue\Socialite\Providers\AbstractProvider::parseAccessToken PHP Method

parseAccessToken() protected method

Get the access token from the token response body.
protected parseAccessToken ( Psr\Http\Message\StreamInterface | array $body ) : AccessToken
$body Psr\Http\Message\StreamInterface | array
return Overtrue\Socialite\AccessToken
    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);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function parseAccessToken($body)
 {
     parse_str($body, $token);
     return parent::parseAccessToken($token);
 }