social-app-django icon indicating copy to clipboard operation
social-app-django copied to clipboard

LinkedIn OAuth2 Problem

Open SebasWilde opened this issue 6 years ago • 14 comments

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

SebasWilde avatar Dec 15 '18 03:12 SebasWilde

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

Manchu-123 avatar May 08 '19 01:05 Manchu-123

same here

johnfidel98 avatar May 17 '19 09:05 johnfidel98

same problem

yfilippenko avatar May 17 '19 14:05 yfilippenko

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

jitendravarma avatar May 21 '19 05:05 jitendravarma

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

SimKennedy avatar May 21 '19 16:05 SimKennedy

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

Amrit0991 avatar May 21 '19 17:05 Amrit0991

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

yfilippenko avatar May 21 '19 17:05 yfilippenko

new error came😖

On Tue, 21 May 2019 at 22:53, Amrit Saini [email protected] 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 .

Manchu-123 avatar May 22 '19 09:05 Manchu-123

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?

apardes avatar May 23 '19 03:05 apardes

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

tuergeist avatar May 29 '19 07:05 tuergeist

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.

awachat avatar May 29 '19 07:05 awachat

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

tuergeist avatar May 29 '19 12:05 tuergeist

@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

tuergeist avatar May 29 '19 18:05 tuergeist

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

jyr avatar Sep 03 '19 15:09 jyr