Esempio n. 1
0
 /**
  * Parse an access token response and assign
  * credential values.
  *
  * @param Vinelab\Http\Response $response
  *
  * @return Vinelab\Auth\Social\Providers\Twitter\OAuthToken
  */
 public function makeAccessToken(Response $response)
 {
     parse_str($response->content(), $params);
     $this->validateAccessTokenResponse($params);
     $this->credentials['key'] = $params['oauth_token'];
     $this->credentials['secret'] = $params['oauth_token_secret'];
     $this->credentials['user_id'] = $params['user_id'];
     $this->credentials['screen_name'] = $params['screen_name'];
     return $this;
 }
Esempio n. 2
0
 /**
  * Parses an access token response.
  *
  * @param Vinelab\Http\Response $response
  *
  * @return array
  */
 public function parseResponse(Response $response)
 {
     $json = $response->json();
     /*
      * The returned response must not be in JSON
      * format, unless it is an error.
      */
     if (!is_null($json)) {
         if (isset($json->error)) {
             $error = $json->error;
             throw new AccessTokenException($error->type . ': ' . $error->message, $error->code);
         }
     }
     $token = $response->content();
     return $this->parseToken($token);
 }