From 0969b607af3cc5de1c5326372f3602fe057654c1 Mon Sep 17 00:00:00 2001 From: "edgars.neimanis" Date: Wed, 21 Oct 2020 11:33:03 +0300 Subject: [PATCH 1/2] facebook fix to get rid of tokenless user picture endpoint --- src/Two/FacebookProvider.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Two/FacebookProvider.php b/src/Two/FacebookProvider.php index 6e65b2e5..a34fecd9 100644 --- a/src/Two/FacebookProvider.php +++ b/src/Two/FacebookProvider.php @@ -48,6 +48,13 @@ class FacebookProvider extends AbstractProvider implements ProviderInterface */ protected $reRequest = false; + /** + * User access token. + * + * @var string|null + */ + private $fbAccesToken; + /** * {@inheritdoc} */ @@ -83,6 +90,8 @@ public function getAccessTokenResponse($code) */ protected function getUserByToken($token) { + $this->fbAccesToken = $token; + $meUrl = $this->graphUrl.'/'.$this->version.'/me?access_token='.$token.'&fields='.implode(',', $this->fields); if (! empty($this->clientSecret)) { @@ -105,15 +114,15 @@ protected function getUserByToken($token) */ protected function mapUserToObject(array $user) { - $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture'; + $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture?access_token=' . $this->fbAccesToken; return (new User)->setRaw($user)->map([ 'id' => $user['id'], 'nickname' => null, 'name' => $user['name'] ?? null, 'email' => $user['email'] ?? null, - 'avatar' => $avatarUrl.'?type=normal', - 'avatar_original' => $avatarUrl.'?width=1920', + 'avatar' => $avatarUrl.'&type=normal', + 'avatar_original' => $avatarUrl.'&width=1920', 'profileUrl' => $user['link'] ?? null, ]); } From 80bd851c173ebb09a428309767eb699d6ee0ba2d Mon Sep 17 00:00:00 2001 From: "edgars.neimanis" Date: Wed, 21 Oct 2020 11:40:05 +0300 Subject: [PATCH 2/2] styleci fix --- src/Two/FacebookProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Two/FacebookProvider.php b/src/Two/FacebookProvider.php index a34fecd9..de947dae 100644 --- a/src/Two/FacebookProvider.php +++ b/src/Two/FacebookProvider.php @@ -114,7 +114,7 @@ protected function getUserByToken($token) */ protected function mapUserToObject(array $user) { - $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture?access_token=' . $this->fbAccesToken; + $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture?access_token='.$this->fbAccesToken; return (new User)->setRaw($user)->map([ 'id' => $user['id'],