+ 3

Next-Auth

Here is a button. SignIn is imported from Next-Auth. I am using next-auth 4 version. <Button ariaLabel="Sign in with Google" onClick={() => SignIn('google')} icon={<Image src={googleIcon} alt="Google icon" />} text="Continue with Google" isLoading={loadingStates.google} /> This is the provider in /pages/api/auth/[...nextauth].ts file GoogleProvider({ clientId: process.env.AUTH_GOOGLE_ID ?? '', clientSecret: process.env.AUTH_GOOGLE_SECRET ?? '', }), this is the callBack callbacks: { async signIn({ user, account }) { const provider = account?.provider; if (provider === 'google') { try { } catch (error) { console.error(`${account?.provider} sign-in error:`, error); return false; } } return true; }, so in try block i want to get a session id in the next-Auth that i get from localstorage. Here is the problem that next-auth is a server file i cannot access local storage in this file and i am not able to send sessionId through signIn method because it does not take the additional arguments. can anyone tell me how can i do it ?? I am again telling that i am using next-auth 4 version. I have read all the next-auth documentation but i have not got a single way to do it so please help me anyone. if you want more explanation. ask me i will provide.

2nd Dec 2024, 5:31 PM
Davinder Kumar
Davinder Kumar - avatar
2 Respuestas
0
This is not what I want. You should read my question carefully. I mentioned there session-id which could be any random id that user will get from localstorage of browser that somehow we will allow to set in user's browser when user will visit on application so through this we make detect session of the application that belong to a particular user. We cannot use token for this. I hope you got more clarity on my question now.
6th Dec 2024, 7:07 PM
Davinder Kumar
Davinder Kumar - avatar