Navigation Menu

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

fix(providers): Include client_id and client_secret in LinkedIn token request #5236

Merged
merged 3 commits into from Sep 7, 2022

Conversation

sildur
Copy link
Contributor

@sildur sildur commented Aug 27, 2022

Linkedin now requires client_id and client_secret to be
sent in the oauth callback. Fixes #5220

Edit: related: https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin%2Fcontext&view=li-lms-2022-08&tabs=HTTPS#step-3-exchange-authorization-code-for-an-access-token

☕️ Reasoning

Linkedin now requires client_id and client_secret to be
sent in the oauth callback. This PR adds them. Fixes #5220

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Please scout and link issues that might be solved by this PR.

Fixes: #5220

📌 Resources

@vercel
Copy link

vercel bot commented Aug 27, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
next-auth ⬜️ Ignored (Inspect) Sep 7, 2022 at 3:57PM (UTC)

@github-actions github-actions bot added core Refers to `@auth/core` providers labels Aug 27, 2022
Linkedin now requires client_id and client_secret to be
sent in the oauth callback. Fixes nextauthjs#5220
@sildur sildur force-pushed the required_fields_for_linkedin branch from 33f66ed to b6d332e Compare August 27, 2022 17:06
Copy link
Member

@ThangHuuVu ThangHuuVu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the PR
I'll merge this once I verified the fix 🙏

@ThangHuuVu ThangHuuVu changed the title Send client_id and client_secret to linkedin fix(providers): Include client_id and client_secret in LinkedIn token request Aug 30, 2022
Comment on lines 33 to 51
token: {
url: "https://www.linkedin.com/oauth/v2/accessToken",
async request({
client,
params,
checks,
provider
}) {
const response = await client.oauthCallback(provider.callbackUrl, params, checks, {
exchangeBody: {
client_id: options.clientId,
client_secret: options.clientSecret,
}
});
return {
tokens: response
};
}
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, you can just add the following config:

client: {
      token_endpoint_auth_method: "client_secret_post",
},

Read more here: https://next-auth.js.org/configuration/providers/oauth#client-option

I verified this locally:
image

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the solution from @balazsorban44 works for me as well, thanks

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Could you please address my review so we can merge this? 🙏

I had the same comment on your other PR here: #5225 (review)

Copy link

@JefferMarcelino JefferMarcelino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Copy link
Member

@balazsorban44 balazsorban44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied the changes, so we can merge this quicker. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Refers to `@auth/core` providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LinkedIn Provider throwing error
5 participants