python-social-auth / social-app-django

Python Social Auth - Application - Django
BSD 3-Clause "New" or "Revised" License
2k stars 374 forks source link

LinkedIn OAuth2 Problem #182

Open SebasWilde opened 5 years ago

SebasWilde commented 5 years ago

Problem with LinkedIn OAuth2 After authentication show this error message

HTTPError at /oauth/complete/linkedin-oauth2/ 410 Client Error: Gone for url: https://api.linkedin.com/v1/people/~:(email-address,first-name,headline,id,industry,last-name)?format=json

Django settings conf Add email to requested authorizations. SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE = ['r_emailaddress', 'r_liteprofile'] Add the fields so they will be requested from linkedin. SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS = [ 'email-address', 'headline', 'industry', ]

social-auth-app-django==3.1.0 social-auth-core==2.0.0 Django==2.1

Manchu-123 commented 5 years ago

I'm also facing the same issue...If you resolved it please let me know.

johnfidel98 commented 5 years ago

same here

yfilippenko commented 5 years ago

same problem

jitendravarma commented 5 years ago

It was working previously, since last week its started throwing this error.

SimKennedy commented 5 years ago

+1 Just got this error here. Anyone found a solution?

Amrit0991 commented 5 years ago

The PyPi version for social-auth-core seems to be behind master from Github, which references v2. This worked for me:

pip uninstall social-auth-core pip install git+https://github.com/python-social-auth/social-core

yfilippenko commented 5 years ago

The PyPi version for social-auth-core seems to be behind master from Github, which references v2. This worked for me:

pip uninstall social-auth-core pip install git+https://github.com/python-social-auth/social-core

Perfect! Works for us

Manchu-123 commented 5 years ago

new error came😖

On Tue, 21 May 2019 at 22:53, Amrit Saini notifications@github.com wrote:

The PyPi version for social-auth-core seems to be behind master from Github, which references v2. This worked for me:

pip uninstall social-auth-core pip install git+https://github.com/python-social-auth/social-core

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/python-social-auth/social-app-django/issues/182?email_source=notifications&email_token=ALWKCHPELJJNKXOU2QUEG3DPWQV2TA5CNFSM4GKSGC6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV4TKIY#issuecomment-494482723, or mute the thread https://github.com/notifications/unsubscribe-auth/ALWKCHIZKDS4IAFTDVZYRE3PWQV2TANCNFSM4GKSGC6A .

apardes commented 5 years ago

I'm experiencing the same issue and it seems to be a recent bug.

@Amrit0991 following your suggestion I was able to resolve the 500 error that was being returned previously but now the auth process just redirects to my SOCIAL_AUTH_LOGIN_ERROR_URL and I see Authentication process canceled in the server console. My other authentication backends continue to work as before.

Any thoughts/suggestions?

tuergeist commented 5 years ago

I'm experiencing the same issue and it seems to be a recent bug.

@Amrit0991 following your suggestion I was able to resolve the 500 error that was being returned previously but now the auth process just redirects to my SOCIAL_AUTH_LOGIN_ERROR_URL and I see Authentication process canceled in the server console. My other authentication backends continue to work as before.

Any thoughts/suggestions?

For me it worked only for new users. Existing users had to be removed. Looking for a migration path right now

awachat commented 5 years ago

As of May 1, 2019, LinkedIn has stopped support for v1 API. The LinkedInOauth2 class in social-auth-core is updated to use v2 API, and the changes are merged to master. Like @Amrit0991 mentioned, the Pypi version is behind the master.

It should solve a lot of issues for most of us.

pip uninstall social-auth-core
pip install git+https://github.com/python-social-auth/social-core

Also, as per the new permission "r_liteprofile", only firstName, lastName, Email and ProfilePictureUrl is available. By default, the LinkedinOauth2 backend on social-auth-core do not support ProfilePictureUrl, but if you are interested, please check this gist.

NOTE:

  1. Use emailAddress instead of email-address. Avoid using industry, headline.
  2. If you are facing issue on the production Django app, copy the Client Id and Client Secret of the prod app and use them on your local dev environment. Mark Debug=False in settings.py. You will know the exact error instead of a generic message Authentication process canceled. This message is added by social-auth-core to throw a 400 instead of 500 on a production app.
  3. As of May 2019, you must add "Product" for LinkedIn App. Check the screenshot and if "Singin with Linkedin" is not listed under "Added Product", please add it using "Add more products" button. image

Please share the error messages.

tuergeist commented 5 years ago

@awachat works for me. (Still having problems on heroku, but seems to be a heroku issue)

tuergeist commented 5 years ago

@awachat works for me. (Still having problems on Heroku, but seems to be a Heroku issue)

heroku does not allow hot patching libs during releasing. Thus I had to change the Pipfile. However, to force an update on social-auth-core I had to bump the version number

social-auth-app-django = "*"
social-auth-core = {version = ">=3.1.1", git = "https://github.com/tuergeist/social-core.git"}

Furthermore, Heroku's caches shall be cleaned: https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache

$ heroku plugins:install heroku-repo
$ heroku repo:purge_cache -a appname
$ git commit --allow-empty -m "Purge cache"
$ git push # or git push heroku master
jyr commented 5 years ago

Hi @SebasWilde

The solution is using:

Django>=2.2 djangorestframework==3.10.1 social-auth-core==3.2.0 social-auth-app-django==3.1.0