Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkedIn with OpenID Connect #3391

Closed
adamghill opened this issue Aug 25, 2023 · 9 comments
Closed

LinkedIn with OpenID Connect #3391

adamghill opened this issue Aug 25, 2023 · 9 comments

Comments

@adamghill
Copy link
Sponsor

First off, thank you for all your work on django-allauth. It is an indispensable addition to the Django ecosystem and I have been very happy with it for the past few years whenever I've needed the functionality.

I created a new LinkedIn App and wanted to use django-allauth to integrate with it. Newly created apps seem to only have a Sign In with LinkedIn using OpenID Connect integration available for authentication purposes.

image

This seems to be a new API that is different than what is supported by the linkedin or linkedin_oauth2 providers. I did also try to use the OpenID and OpenID Connect providers in django-allauth, but couldn't figure out how to make them work with LinkedIn's offering. More details about their OpenID Connect product: https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/sign-in-with-linkedin-v2.

I ended up creating a new provider for django-allauth based on linkedin_oauth2 that implements the correct API calls -- it all seems to work with my testing. I would be happy to polish up my code, add more tests, write docs, and create a PR to add this functionality if you would be interested.

Thanks again for all that you do! 🚀

@pennersr
Copy link
Owner

I haven't looked into this myself yet, but I would like to understand why the current OIDC implementation of allauth does not work with LinkedIn. Is there anything our OIDC implementation is missing, or, is the LinkedIn OIDC implementation not fully OIDC compliant? Preferably, we fix the OIDC implementation in allauth if it needs fixing instead of adding a new LinkedIn provider...

@adamghill
Copy link
Sponsor Author

Apologies, I read through the LinkedIn documentation for OpenID Connect again and found the link to the discovery document.

Now, the server_url is correct in my settings and everything looks like it is working with the regular OpenID Connect provider.

image

Sorry for creating an unnecessary issue -- I'll close this now. Thanks again for django-allauth and all your help!

@kiranchari
Copy link

kiranchari commented Oct 1, 2023

@adamghill Thanks for posting your solution here, I had the same issue. Do you know if it is possible to retrieve a linkedin user's profile url using open id connect?

@adamghill
Copy link
Sponsor Author

@kiranchari I don't see a way to get the profile url. The sample response in the docs is a little different than my testing -- the JSON I see looks like this:

{
    "sub": "REDACTED",
    "email_verified": true,
    "name": "Adam Hill",
    "locale": {"country": "US", "language": "en"},
    "given_name": "Adam",
    "family_name": "Hill",
    "email": "REDACTED",
    "picture": "REDACTED"
}

sub is an identifier for LinkedIn, but I don't know of a way to convert that member id to a profile url, unfortunately.

@actiotec
Copy link

actiotec commented Apr 19, 2024

Can someone please provide me with the exact procedure to use openid_connect with LinkedIn?

I have the following settings:
'openid_connect': { "APPS":[ { 'provider_id': 'linkedin', 'name': 'Linkedin openid connect', 'client_id': 'XXX', 'client_secret': 'XXX', 'server_url':'https://www.linkedin.com/oauth/v2/authorization', 'scope': ['email', 'profile'], #'redirect_uri': 'http://localhost:8000/accounts/oidc/linkedin/login/callback/', }, ] },

And I'm wondering how to use it (if settings are correct) in my template with something like:
<a href="{% provider_login_url 'linkedin' %}" class="linkedin-btn mt-2">

Thanks a lot!

@adamghill
Copy link
Sponsor Author

@actiotec The settings you have are different than mine in #3391 (comment). I'd suggest trying the ones in my comment since that worked for me.

@actiotec
Copy link

@actiotec The settings you have are different than mine in #3391 (comment). I'd suggest trying the ones in my comment since that worked for me.

Thanks but how do you then use it in your templates? And what is the redirect URL then ?

Thanks in advance

@actiotec
Copy link

@actiotec The settings you have are different than mine in #3391 (comment). I'd suggest trying the ones in my comment since that worked for me.

Thanks but how do you then use it in your templates? And what is the redirect URL then ?

Thanks in advance

A small up, nobody to help me out? Would be really appreciated. Thanks in advance!

@subzii
Copy link

subzii commented Jun 28, 2024

@actiotec
<a href="{% provider_login_url 'provider_id' %}" class="linkedin-btn mt-2"> is how you use it in a template, just replace the provider_id with what you have in your settings openid_connect config...
http://127.0.0.1:8000/accounts/oidc/provider_id/login/callback/ is the callback, again replace the provider_id, based on your config it will be linkedin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants