Next.js Discord

Discord Forum

Next auth token

Unanswered
Russian Blue posted this in #help-forum
Open in Discord
Russian BlueOP
The token is giving me an error, is it not available anymore?

26 Replies

Can you hover on it and see what the error is?
...
  callbacks: {
    async signIn({ user, account, profile, email, credentials }) {
      return true
    },
    async redirect({ url, baseUrl }) {
      return baseUrl
    },
    async session({ session, user, token }) {
      return session
    },
    async jwt({ token, user, account, profile, isNewUser }) {
      return token
    }
...
}
On the session callback make a fetch to the db
const user = await prisma.user.findUnique({
  where: {
    email: 'elsa@prisma.io',
  },
})
U can use the select option to only get the token
select: {
    token: true
  },
Then modify the session object to add the token
session.token = token

and return the session
return session
Russian BlueOP
but this is new, I used to do the same thing with no errors?
@Nelson
I am using the newer documentation
called authjs
what next-auth version?
Russian BlueOP
"next-auth": "^5.0.0-beta.5"
V5
try 5.0.0-beta.4
Russian BlueOP
sill the same
try to delete node_modules, .lock, restart vscode and install all again
Russian BlueOP
oh you have the same error?
Nop, i only copied the code
Russian BlueOP
tried what u said above, still same issue which is weird tbh akhh
But u get the token value?
Russian BlueOP
yes works fine ig
yes I can pass data from token to session normally
but this error is bugging me, even thought i implemented the same stuff about a week ago and didn't face any errors back
Try to reload the TS Server,
open the Command Palette (Ctrl+Shift+P) and search reload TS server
Russian BlueOP
Looks like it’s an error with the new update, there is an open issue on github