laravel / socialite

Laravel wrapper around OAuth 1 & OAuth 2 libraries.
https://laravel.com/docs/socialite
MIT License
5.58k stars 940 forks source link

Updating 2.0 To Support V2 LinkedIn Endpoints #367

Closed pihish closed 5 years ago

pihish commented 5 years ago

LinkedIn deprecated their V1 login endpoints at the start of this month. Only the new V2 endpoints can be used going forward. I noticed that while the 4.0 branch has been updated to reflect the new V2 endpoints, branches 2.0 and 3.0 are still pointing to the old V1 endpoints.

Is there a way we can make minor updates to version 2.0 so that it points to the V2 URLs? I am currently working on a project with Laravel 5.0 and PHP 5.6 so cannot upgrade to 4.0.

From what I can tell, the $url variable inside of the getUserByToken() method in LinkedInProvider.php needs to be updated from:

$url = 'https://api.linkedin.com/v1/people/~:('.$fields.')';

to

$url = 'https://api.linkedin.com/v2/me/?projection=('.$fields.')';

protected $scopes = ['r_basicprofile', 'r_emailaddress'];

also needs to be changed to

protected $scopes = ['r_liteProfile', 'r_emailaddress'];

at the top of the file. By default, LinkedIn will only grant access to a "lite" profile now unless you explicitly request expanded access by submitting a support ticket with them.

Not sure if there are any other items that need to be changed. If so, please chime in. I am happy to add a pull request for this if need be.

driesvints commented 5 years ago

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting.

Thanks!

lazyguru commented 5 years ago

Hi @driesvints the support policy says Laravel 5.5 (LTS) is supported for bug fixes until August 2019. Since 4.0 requires Laravel 5.7 or newer (See release notes: https://github.com/laravel/socialite/releases/tag/v4.0.0), that would mean the 3.x branch is the highest level supported for Laravel 5.5. What can be done to update the 3.x branch so that Laravel 5.5 is still supported? (If I submit a PR, will it get attention?)

driesvints commented 5 years ago

Hey @lazyguru. LTS support is only for the framework itself, not the packages. Please see: https://laravel.com/docs/5.8/releases#support-policy

For all additional libraries, including Lumen, only the latest release receives bug fixes.

lazyguru commented 5 years ago

Fair enough. I've solved it for my use-case by following the "custom driver" instructions and just copying the LinkedIn driver from the 4.x branch into my codebase

pihish commented 5 years ago

@lazyguru Can you post a link to the "custom driver" guide you followed?

lazyguru commented 5 years ago

I followed this, but only step 4 since I was just reusing the existing driver but with a different namespace: https://medium.com/laravel-news/adding-auth-providers-to-laravel-socialite-ca0335929e42

pihish commented 5 years ago

@lazyguru Thanks. Did you run into a namespace issue when trying to boot up the new service provider? Specifically, the following in the guide:

return $socialite->buildProvider(SpotifyProvider::class, $config);

I get an Class 'Laravel\Socialite\Two\LinkedInV2ServiceProvider' not found error. The name of class and file is LinkedInV2ServiceProvider and I have it under the Laravel\Socialite\Two namespace.

lazyguru commented 5 years ago

Make sure you have a “namespace” line at the top of the file. I think that guide is missing it. Also, I put mine in my install (not in its own package) so the name space ended up being something like “\App\Providers” (don’t have the code in front of me to check exactly)