Skip to content

Commit

Permalink
[5.x] Update LinkedInProvider.php (#670)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2023
1 parent 444b2c7 commit e7e4eaa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/Two/LinkedInProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).")",
],
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/LinkedInProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down

0 comments on commit e7e4eaa

Please sign in to comment.