How to access authorization code in token request? #4645
-
Question 💬I have set up a working authorization endpoint override that returns a valid code, but I need to also override the token endpoint and make a call using the previously received code. Is there a way to retrieve it using the url/params method described as 2 (https://next-auth.js.org/configuration/providers/oauth#token-option) I'm able to use technique 3 described above and complete the request, but I'm not sure how to construct the tokens object that should be returned by the token callback function. Is there documentation on that? How to reproduce ☕️token: {
url: "https://login.microsoftonline.com/consumers/oauth2/v2.0/token",
params: {
client_id: process.env.MICROSOFT_CLIENT_ID,
client_secret: process.env.MICROSOFT_CLIENT_SECRET,
code: "WHAT CAN I PUT HERE?",
grant_type: 'authorization_code',
redirect_uri: "http://localhost:3000/api/auth/callback/azure-ad"
} Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
having the same trouble here |
Beta Was this translation helpful? Give feedback.
-
You don't need to set Check this diagram to understand how OAuth works with NextAuth.js: https://next-auth.js.org/configuration/providers/oauth |
Beta Was this translation helpful? Give feedback.
You don't need to set
code
, it is handled by your Identity Provider.Check this diagram to understand how OAuth works with NextAuth.js: https://next-auth.js.org/configuration/providers/oauth