From 7446829c3b86a8a162f3c06718718c608b78a730 Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Mon, 23 Feb 2015 12:14:17 -0600 Subject: [PATCH 1/2] replace custom code in AccessToken with Vkontakte::$uidKey --- src/Provider/Vkontakte.php | 3 +-- src/Token/AccessToken.php | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Provider/Vkontakte.php b/src/Provider/Vkontakte.php index 7c46ca8..da44ae2 100644 --- a/src/Provider/Vkontakte.php +++ b/src/Provider/Vkontakte.php @@ -7,8 +7,7 @@ use League\OAuth2\Client\Token\AccessToken; class Vkontakte extends AbstractProvider { - public $scopes = []; - public $responseType = 'json'; + public $uidKey = 'user_id'; public function urlAuthorize() { diff --git a/src/Token/AccessToken.php b/src/Token/AccessToken.php index 12cdb67..9a39f55 100755 --- a/src/Token/AccessToken.php +++ b/src/Token/AccessToken.php @@ -46,9 +46,6 @@ class AccessToken // Some providers (not many) give the uid here, so lets take it isset($options['uid']) and $this->uid = $options['uid']; - // Vkontakte uses user_id instead of uid - isset($options['user_id']) and $this->uid = $options['user_id']; - // Mailru uses x_mailru_vid instead of uid isset($options['x_mailru_vid']) and $this->uid = $options['x_mailru_vid']; From 6373453f789895c3b8f573aea75e3e739cc217ee Mon Sep 17 00:00:00 2001 From: Woody Gilk Date: Mon, 23 Feb 2015 12:15:25 -0600 Subject: [PATCH 2/2] remove custom provider code from AccessToken --- src/Token/AccessToken.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Token/AccessToken.php b/src/Token/AccessToken.php index 9a39f55..bcfbfb1 100755 --- a/src/Token/AccessToken.php +++ b/src/Token/AccessToken.php @@ -43,14 +43,13 @@ class AccessToken $this->accessToken = $options['access_token']; - // Some providers (not many) give the uid here, so lets take it - isset($options['uid']) and $this->uid = $options['uid']; + if (!empty($options['uid'])) { + $this->uid = $options['uid']; + } - // Mailru uses x_mailru_vid instead of uid - isset($options['x_mailru_vid']) and $this->uid = $options['x_mailru_vid']; - - //Battle.net uses accountId instead of uid - isset($options['accountId']) and $this->uid = $options['accountId']; + if (!empty($options['refresh_token'])) { + $this->refreshToken = $options['refresh_token']; + } // We need to know when the token expires. Show preference to // 'expires_in' since it is defined in RFC6749 Section 5.1. @@ -64,9 +63,6 @@ class AccessToken $expiresInFuture = $expires > time(); $this->expires = $expiresInFuture ? $expires : time() + ((int) $expires); } - - // Grab a refresh token so we can update access tokens when they expires - isset($options['refresh_token']) and $this->refreshToken = $options['refresh_token']; } /**