public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     $fields = ['first_name', 'last_name', 'nickname', 'screen_name', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo_50', 'photo_100', 'photo_200_orig', 'has_mobile', 'contacts', 'education', 'online', 'counters', 'relation', 'last_seen', 'status', 'can_write_private_message', 'can_see_all_posts', 'can_see_audio', 'can_post', 'universities', 'schools', 'verified'];
     $userId = $token->getResourceOwnerId();
     $tokenValue = $token->getToken();
     return "https://api.vk.com/method/users.get?user_id={$userId}&fields=" . implode($this->getScopeSeparator(), $fields) . "&access_token={$tokenValue}";
 }
 /**
  * Returns an authenticated API client.
  *
  * Requires optional Gitlab API client to be installed.
  *
  * @return Client
  */
 public function getApiClient()
 {
     if (!class_exists('\\Gitlab\\Client')) {
         throw new \LogicException(__METHOD__ . ' requires package m4tthumphrey/php-gitlab-api to be installed and autoloaded');
         // @codeCoverageIgnore
     }
     $client = new Client(rtrim($this->domain, '/') . self::PATH_API);
     return $client->authenticate($this->token->getToken(), Client::AUTH_OAUTH_TOKEN);
 }
 /**
  * Returns the Access Token, or try to reauthenticate if needed
  *
  * @return string
  */
 public function getAccessToken()
 {
     // maybe the token will expire in next 10 seconds
     $expiryCutoff = new \DateTime('+10 seconds');
     // if the token expires try to reauthenticate
     if (!$this->accessToken or $this->getExpires() < $expiryCutoff->getTimestamp()) {
         $this->authenticate();
     }
     return $this->accessToken->getToken();
 }
 /**
  * Create an authentication cookie.
  *
  * @param string      $path
  * @param AccessToken $accessToken
  *
  * @return \Symfony\Component\HttpFoundation\Cookie
  */
 public static function create($path, AccessToken $accessToken)
 {
     if (!($expire = $accessToken->getExpires())) {
         $expire = time() + 3600;
     }
     return new CookieBase(TokenManager::TOKEN_COOKIE_NAME, $accessToken->getToken(), $expire, $path);
 }
 /**
  * @return string Actual access token - does not include refresh or expiry
  * @throws FitbitTokenMissingException
  */
 public function getAccessToken()
 {
     if (empty($this->access_token)) {
         throw new FitbitTokenMissingException();
     }
     return $this->access_token->getToken();
 }
Example #6
0
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     $params = ['fields' => $this->userFields, 'access_token' => $token->getToken(), 'v' => $this->version, 'lang' => $this->lang];
     $query = $this->buildQueryString($params);
     $url = "{$this->baseUri}/users.get?{$query}";
     return $url;
 }
Example #7
0
 /**
  * Executes a request
  *
  * @param string|array|GuzzleHttp\Psr7\Uri $uri String, url template array or URL object
  * @param string $method
  * @param array|GuzzleHttp\Query $query
  * @param string|array|object $data
  * @param array $headers
  * @return array|string|bool
  * @throws GuzzleHttp\Exception\RequestException
  */
 public function exec($uri, $method = 'GET', $query = null, $data = null, array $headers = [])
 {
     if (is_array($uri)) {
         $uri = \GuzzleHttp\uri_template($uri[0], $uri[1]);
     }
     $method = strtoupper($method);
     if (!isset($headers['Authorization']) && null !== $this->token) {
         $headers['Authorization'] = 'Bearer ' . $this->token->getToken();
     }
     $reqOptions = ['headers' => $headers];
     if (is_array($query) || $query instanceof Query) {
         $reqOptions['query'] = $query;
     }
     if ($data !== null) {
         $this->handleRequestData($method, $data, $reqOptions);
     }
     $resp = $this->tryRequest($method, $uri, $reqOptions);
     if ($resp->getStatusCode() === 204) {
         // No Content, just return true
         return true;
     }
     return $this->parseResponse($resp);
 }
Example #8
0
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     $fields = ['id', 'name', 'first_name', 'last_name', 'email', 'hometown', 'picture.type(large){url,is_silhouette}', 'cover{source}', 'gender', 'locale', 'link', 'timezone', 'age_range'];
     // backwards compatibility less than 2.8
     if ((double) substr($this->graphApiVersion, 1) < 2.8) {
         $fields[] = 'bio';
     }
     $appSecretProof = AppSecretProof::create($this->clientSecret, $token->getToken());
     return $this->getBaseGraphUrl() . $this->graphApiVersion . '/me?fields=' . implode(',', $fields) . '&access_token=' . $token . '&appsecret_proof=' . $appSecretProof;
 }
Example #9
0
 protected function getOpenidUrl(AccessToken $token)
 {
     return 'https://graph.qq.com/oauth2.0/me?' . http_build_query(['access_token' => $token->getToken()]);
 }
Example #10
0
 /**
  * Revokes authorization
  * @see https://www.cronofy.com/developers/api/#revoke-authorization
  *
  * @param AccessToken $token
  * @throws IdentityProviderException
  */
 public function revokeToken(AccessToken $token)
 {
     $request = $this->createRequest('POST', 'https://api.cronofy.com/oauth/token/revoke', null, ['headers' => ['Content-Type' => 'application/json; charset=utf-8'], 'body' => json_encode(['client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'token' => $token->getRefreshToken() ?: $token->getToken()])]);
     $this->getResponse($request);
 }
Example #11
0
 /**
  * Returns the URL for requesting the resource owner's details.
  *
  * @param AccessToken $token
  * @return string
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return sprintf('%s/users/me?oauth_token=%s', $this->baseUrl, $token->getToken());
 }
Example #12
0
 /**
  * Get provider url to fetch user details
  *
  * @param AccessToken $token
  *
  * @return string
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return 'https://api.deezer.com/user/me?' . http_build_query(['access_token' => $token->getToken()]);
 }
 /**
  * @param AccessToken $token
  *
  * @return ApiClient
  */
 private function getApiClient(AccessToken $token)
 {
     return new ApiClient($token->getToken(), new Client(['timeout' => 2]));
 }
 /**
  * Get provider url to fetch user details
  *
  * @param AccessToken $token
  *
  * @return string
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return 'https://api.digitalocean.com/v2/account?' . http_build_query(['access_token' => $token->getToken()]);
 }
 /**
  * Creates new MerchantOS
  *
  * @param AccessToken $token
  * @param mixed $accountId
  */
 public function __construct(AccessToken $token, $accountId)
 {
     $this->oauthToken = $token->getToken();
     $this->accountId = $accountId;
 }
Example #16
0
 /**
  * @param AccessToken $token
  * @return string
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return Config::get('laravel-oauth2-client.server_url_user_details') . '?access_token=' . $token->getToken();
 }
Example #17
0
 /**
  * @param AccessToken $token
  *
  * @return string
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return $this->domain . '/api/auth.test?token=' . $token->getToken();
 }
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     $fields = implode(',', ['id', 'name', 'first_name', 'last_name', 'email', 'hometown', 'bio', 'picture.type(large){url,is_silhouette}', 'cover{source}', 'gender', 'locale', 'link', 'timezone', 'birthday']);
     $appSecretProof = AppSecretProof::create($this->clientSecret, $token->getToken());
     return static::BASE_GRAPH_URL . $this->graphApiVersion . '/me?fields=' . $fields . '&access_token=' . $token . '&appsecret_proof=' . $appSecretProof;
 }
Example #19
0
 /**
  * @see https://vk.com/dev/friends.get
  *
  * @param integer          $userId
  * @param AccessToken|null $token
  * @param array            $params
  *
  * @return User[]
  */
 public function friendsGet($userId, AccessToken $token = null, array $params = [])
 {
     $default = ['user_id' => $userId, 'fields' => $this->userFields, 'access_token' => $token ? $token->getToken() : null, 'v' => $this->version, 'lang' => $this->language];
     $params = array_merge($default, $params);
     $query = $this->buildQueryString($params);
     $url = "{$this->baseUri}/friends.get?{$query}";
     $response = $this->getResponse($this->createRequest(static::METHOD_GET, $url, $token, []))['response'];
     $friends = !empty($response['items']) ? $response['items'] : $response;
     $array2friend = function ($friendData) {
         if (is_numeric($friendData)) {
             $friendData = ['id' => $friendData];
         }
         return new User($friendData);
     };
     return array_map($array2friend, $friends);
 }
 /**
  * Find a token matching the given parameters, or create one if it doesn't exist
  *
  * @param string $provider
  * @param AccessToken $token
  * @return self
  */
 public static function createFromAccessToken($provider, AccessToken $token)
 {
     $data = ['Provider' => $provider, 'Token' => $token->getToken(), 'RefreshToken' => $token->getRefreshToken(), 'Expires' => $token->getExpires(), 'ResourceOwnerID' => $token->getResourceOwnerId()];
     $token = static::create()->update($data);
     return $token;
 }
Example #21
0
 /**
  * {@inheritdoc}
  */
 public function getResourceOwnerDetailsUrl(AccessToken $token)
 {
     return 'https://login.yandex.ru/info?format=json&oauth_token=' . $token->getToken();
 }
Example #22
0
 /**
  * Revoke access for the given token.
  *
  * @param AccessToken $accessToken
  *
  * @return mixed
  */
 public function revoke(AccessToken $accessToken)
 {
     $options = $this->getAccessTokenOptions([]);
     $uri = $this->appendQuery(self::BASE_FITBIT_API_URL . '/oauth2/revoke', $this->buildQueryString(['token' => $accessToken->getToken()]));
     $request = $this->getRequest(self::METHOD_POST, $uri, $options);
     return $this->getResponse($request);
 }
Example #23
0
 /**
  * Returns the accessToken
  * @return string
  */
 public function getAccessToken()
 {
     return $this->_accessToken->getToken();
 }