From e7e4eaaeb966463a938ab87a4151d598bdafe4ee Mon Sep 17 00:00:00 2001 From: moha-ep <106144010+moha-ep@users.noreply.github.com> Date: Mon, 30 Oct 2023 23:09:49 +0100 Subject: [PATCH] [5.x] Update LinkedInProvider.php (#670) * Update LinkedInProvider.php Add vanityName on query * Update LinkedInProvider.php * [5.x.x] Update LinkedInProvider.php * Update LinkedInProviderTest.php * Update LinkedInProvider.php --------- Co-authored-by: Dries Vints Co-authored-by: Taylor Otwell --- src/Two/LinkedInProvider.php | 10 ++++++++-- tests/LinkedInProviderTest.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Two/LinkedInProvider.php b/src/Two/LinkedInProvider.php index 78159ba8..ed5e518f 100644 --- a/src/Two/LinkedInProvider.php +++ b/src/Two/LinkedInProvider.php @@ -55,14 +55,20 @@ protected function getUserByToken($token) * @return array */ protected function getBasicProfile($token) - { + { + $fields = ["id","firstName","lastName","profilePicture(displayImage~:playableStreams)"]; + + if (in_array('r_liteprofile', $this->getScopes())) { + array_push($fields, 'vanityName'); + } + $response = $this->getHttpClient()->get('https://api.linkedin.com/v2/me', [ RequestOptions::HEADERS => [ 'Authorization' => 'Bearer '.$token, 'X-RestLi-Protocol-Version' => '2.0.0', ], RequestOptions::QUERY => [ - 'projection' => '(id,firstName,lastName,profilePicture(displayImage~:playableStreams))', + 'projection' => "(".implode(',',$fields).")", ], ]); diff --git a/tests/LinkedInProviderTest.php b/tests/LinkedInProviderTest.php index 8f92ac75..ca9c9408 100644 --- a/tests/LinkedInProviderTest.php +++ b/tests/LinkedInProviderTest.php @@ -53,7 +53,7 @@ public function test_it_can_map_a_user_without_an_email_address() 'X-RestLi-Protocol-Version' => '2.0.0', ], RequestOptions::QUERY => [ - 'projection' => '(id,firstName,lastName,profilePicture(displayImage~:playableStreams))', + 'projection' => '(id,firstName,lastName,profilePicture(displayImage~:playableStreams),vanityName)', ], ])->andReturns($basicProfileResponse); $guzzle->allows('get')->with('https://api.linkedin.com/v2/emailAddress', [