getToken() public method

Return the access token string.
public getToken ( ) : string
return string
Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $userUrl = 'https://api.github.com/user?access_token=' . $token->getToken();
     $response = $this->getHttpClient()->get($userUrl, $this->getRequestOptions());
     $user = json_decode($response->getBody(), true);
     if (in_array('user:email', $this->scopes)) {
         $user['email'] = $this->getEmailByToken($token);
     }
     return $user;
 }
Example #2
0
 /**
  * Get the raw user for the given access token.
  *
  * @param \Overtrue\Socialite\AccessTokenInterface $token
  *
  * @return array
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $response = $this->getHttpClient()->get($this->baseUrl . '/' . $this->version . '/users/show.json', ['query' => ['uid' => $token['uid'], 'access_token' => $token->getToken()], 'headers' => ['Accept' => 'application/json']]);
     return json_decode($response->getBody(), true);
 }
Example #3
0
 /**
  * {@inheritdoc}.
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $response = $this->getHttpClient()->get($this->baseUrl . '/userinfo', ['query' => ['access_token' => $token->getToken(), 'openid' => $token['openId'], 'lang' => 'zh_CN']]);
     return json_decode($response->getBody(), true);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $appSecretProof = hash_hmac('sha256', $token->getToken(), $this->clientSecret);
     $response = $this->getHttpClient()->get($this->graphUrl . '/' . $this->version . '/me?access_token=' . $token . '&appsecret_proof=' . $appSecretProof . '&fields=' . implode(',', $this->fields), ['headers' => ['Accept' => 'application/json']]);
     return json_decode($response->getBody(), true);
 }
Example #5
0
 /**
  * Get the raw user for the given access token.
  *
  * @param \Overtrue\Socialite\AccessTokenInterface $token
  *
  * @return array
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $url = $this->baseUrl . '/oauth2.0/me?access_token=' . $token->getToken();
     $this->withUnionId && ($url .= '&unionid=1');
     $response = $this->getHttpClient()->get($url);
     $me = json_decode($this->removeCallback($response->getBody()->getContents()), true);
     $this->openId = $me['openid'];
     $this->unionId = isset($me['unionid']) ? $me['unionid'] : '';
     $queries = ['access_token' => $token->getToken(), 'openid' => $this->openId, 'oauth_consumer_key' => $this->clientId];
     $response = $this->getHttpClient()->get($this->baseUrl . '/user/get_user_info?' . http_build_query($queries));
     return json_decode($this->removeCallback($response->getBody()->getContents()), true);
 }
Example #6
0
 /**
  * Get the raw user for the given access token.
  *
  * @param \Overtrue\Socialite\AccessTokenInterface $token
  *
  * @return array
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $response = $this->getHttpClient()->get($this->baseUrl . '/oauth2.0/me?access_token=' . $token->getToken());
     $this->openId = json_decode($this->removeCallback($response->getBody()->getContents()), true)['openid'];
     $queries = ['access_token' => $token->getToken(), 'openid' => $this->openId, 'oauth_consumer_key' => $this->clientId];
     $response = $this->getHttpClient()->get($this->baseUrl . "/user/get_user_info?" . http_build_query($queries));
     return json_decode($this->removeCallback($response->getBody()->getContents()), true);
 }
Example #7
0
 /**
  * {@inheritdoc}.
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $response = $this->getHttpClient()->get('https://api.douban.com/v2/user/~me', ['headers' => ['Authorization' => 'Bearer ' . $token->getToken()]]);
     return json_decode($this->removeCallback($response->getBody()->getContents()), true);
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $response = $this->getHttpClient()->get('https://www.googleapis.com/plus/v1/people/me?', ['query' => ['prettyPrint' => 'false'], 'headers' => ['Accept' => 'application/json', 'Authorization' => 'Bearer ' . $token->getToken()]]);
     return json_decode($response->getBody(), true);
 }
Example #9
0
 /**
  * {@inheritdoc}.
  */
 protected function getUserByToken(AccessTokenInterface $token)
 {
     $scopes = explode(',', $token->getAttribute('scope', ''));
     if (in_array('snsapi_base', $scopes)) {
         return $token->toArray();
     }
     if (empty($token['openid'])) {
         throw new InvalidArgumentException('openid of AccessToken is required.');
     }
     $response = $this->getHttpClient()->get($this->baseUrl . '/userinfo', ['query' => ['access_token' => $token->getToken(), 'openid' => $token['openid'], 'lang' => 'zh_CN']]);
     return json_decode($response->getBody(), true);
 }