next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

How to access authorization code in token request?

Open Potrock opened this issue 4 years ago • 1 comments

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

Potrock avatar May 25 '22 01:05 Potrock

having the same trouble here

si4star avatar May 27 '22 13:05 si4star