How to use code in url param to exchange tokens with custom providers in next-auth?
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
So I have created a custom provider in next auth like this :
It works as in user can sign in with this but I am not able to create a session object as all I get from this is that user gets redirected to home page with a code in url params and now I need to send this code to exchange tokens. But how do I do it here? For some reason this provider is not even reaching the callback
callback :
But it won't register this log while the providers as provided by next auth works fine, only my custom provider is not able to start this callback.
{
id: "oidc",
name: "OIDC",
type: "oauth",
authorization: {
url: "https://www.mywebsite.com/oauth2/authorize",
params: {
scope: "openid email profile aws.cognito.signin.user.admin",
response_type: "code",
client_id: process.env.CLIENT_ID,
redirect_uri: "http://localhost:3000",
identity_provider: "Google-OIDC",
},
},
idToken: true,
checks: ["state"],
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
},It works as in user can sign in with this but I am not able to create a session object as all I get from this is that user gets redirected to home page with a code in url params and now I need to send this code to exchange tokens. But how do I do it here? For some reason this provider is not even reaching the callback
callback :
session: { strategy: "jwt", maxAge: 30 * 24 * 60 * 60 },
callbacks: {
async jwt({ token, trigger, account, user, session }) {
console.log("I am here, yes I am");But it won't register this log while the providers as provided by next auth works fine, only my custom provider is not able to start this callback.