thephpleague / oauth2-linkedin

LinkedIn Provider for the OAuth 2.0 Client
MIT License
83 stars 37 forks source link

Use only LinkedIn API v2 with new default scope 'r_liteprofile' #23

Closed vyskocilpavel closed 5 years ago

vyskocilpavel commented 5 years ago

Use only LinkedIn API v2 with new default scope 'r_liteprofile' because LinkedIn is going to stop Sign In via OAuth1.0.

ocean90 commented 5 years ago

Another change is that getFirstName() and getLastName are now returning a MultiLocaleString object. It's basically an array and looks like this:

array(3) {
    ["lastName"]=>
    array(2) {
      ["localized"]=>
      array(1) {
        ["de_DE"]=>
        string(9) "Schilling"
      }
      ["preferredLocale"]=>
      array(2) {
        ["country"]=>
        string(2) "DE"
        ["language"]=>
        string(2) "de"
      }
    }
    ["firstName"]=>
    array(2) {
      ["localized"]=>
      array(1) {
        ["de_DE"]=>
        string(7) "Dominik"
      }
      ["preferredLocale"]=>
      array(2) {
        ["country"]=>
        string(2) "DE"
        ["language"]=>
        string(2) "de"
      }
    }
OJezu commented 5 years ago

I would be nice if we could be still getting email address and real profilePicture url in resource owner informartion. I see email support is removed, and AFAIK, the profilePicture is now some kind of pointer, not a downloadable URL.

gvso commented 5 years ago

I agree with @OJezu. That would be nice!

OJezu commented 5 years ago

I've added a PR to the PR https://github.com/pajavyskocil/oauth2-linkedin/pull/1

PR:

nibsirahsieu commented 5 years ago

Is there a way to grab linkedin profile url? seems its removed in API v2

OJezu commented 5 years ago

@nibsirahsieu It was removed, but there is vanityName which can be used to construct profile URL. You can get vanityName by adding it to requested fields.

According to LinkedIn API Doc, every member should have a vanity name. https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-vanity-name-api?context=linkedin/compliance/context

OJezu commented 5 years ago

@stevenmaguire Is there anything preventing this from getting merged? All functionality has been ported to V2, tests have been added, doc was updated, and if LinkedIn does not alter it's plans, the package will stop working in 5 days.

I think this should be a new major version though, as scopes, fields are different, and the api version cannot be switched.

vyskocilpavel commented 5 years ago

@stevenmaguire Is there anything preventing this from getting merged? All functionality has been ported to V2, tests have been added, doc was updated, and if LinkedIn does not alter it's plans, the package will stop working in 5 days.

I think this should be a new major version though, as scopes, fields are different, and the api version cannot be switched.

I only fixed the typo in default scopes

nibsirahsieu commented 5 years ago

Hi @pajavyskocil , i've tried your fork, but i always got error 'Not enough permissions to access: GET /me'. Do you know how to solve the issue?

Edit: Solved. Sorry, i have override default scopes.

stevenmaguire commented 5 years ago

Thank you all for your patience and valuable research into the migration path away from LinkedIn API Version 1. I apologize for any frustration the delay in package update may have caused, especially as it relates to the breaking changes in your own projects caused by LinkedIn's deprecation of their API. It is not lost on me that the main concern here was the behavior of the package related to accessing resource owner details - the secondary function of this and all oauth2-client packages.

This package has now been updated to remove support for LinkedIn's API Version 1 and has been tailored specifically to LinkedIn's API Version 2. It now includes many (not all) of the changes that were proposed in this PR - which was great work! I did not merge the PR in whole because some of the changes proposed were invasive enough that it would've taken longer to remove (or request changes from you) than to add. You can find these changes in a new 5.0.0 release. The README has been updated.

If you encounter any issues with the new version, please open up a new issue.

I would like to point out, and perhaps remind you, this package is not intended to serve as an API Client for LinkedIn. The primary function of this package - retrieval of access tokens themselves - should not have been affected by the changes made on LinkedIn's side and the package supports setting any scopes that are required for OAuth2 flow. I hope this proved to be true for most of you. If not, I am curious to hear anecdotes of where access token flows failed during this time. That's not an excuse for the delayed update to the package - I point that out to encourage you to separate those concerns in your own projects. The fact that this package offers basic Resource Owner details is a courtesy or nice-to-have.