You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using NextAuth (^4.24.5) in my Next.js (14.2.15) application with the app directory. I've set up authentication with both the Email provider and the Google OAuth provider.
In my login form, I'm passing additional custom data to the signIn function as the third argument. Here's my code:
When I log in using the Email provider, I can access the custom data ({ title: "credits" }) in the req object within the signIn callback. Specifically, I see it in req.searchParams:
However, when I log in using the Google OAuth provider, the custom data is not present in the req object within the signIn callback.
My Question:
1. Why can't I access the custom data passed to signIn when using Google OAuth provider?
2. Do I need to configure something differently to make this data available in the signIn?
3. Is there a recommended way to persist custom data through the OAuth flow with providers like Google so that it can be accessed in the signIn callback?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey folks,
I'm using NextAuth (^4.24.5) in my Next.js (14.2.15) application with the
app
directory. I've set up authentication with both the Email provider and the Google OAuth provider.In my login form, I'm passing additional custom data to the
signIn
function as the third argument. Here's my code:Notice that I am passing
{ title: "credits" }
as the third argument to thesignIn
function for both the providers.The
/api/auth/[....nextauth]/route.ts
file looks like this:Here is the simplified
signIn
callback inside myauth.ts
file:When I log in using the Email provider, I can access the custom data ({ title: "credits" }) in the
req
object within thesignIn
callback. Specifically, I see it inreq.searchParams
:However, when I log in using the Google OAuth provider, the custom data is not present in the
req
object within thesignIn
callback.My Question:
1. Why can't I access the custom data passed to
signIn
when using Google OAuth provider?2. Do I need to configure something differently to make this data available in the
signIn
?3. Is there a recommended way to persist custom data through the OAuth flow with providers like Google so that it can be accessed in the
signIn
callback?Beta Was this translation helpful? Give feedback.
All reactions