diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index 1a1b57a0552..1228d39b756 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -65,8 +65,9 @@ export const authOptions = { async session({ session, token }) { await connectMongo(); // Send properties to the client, like an access_token and user id from a provider. + // note: `sub` is the user id session.accessToken = token.accessToken; - session.user.id = token.id; + session.user.id = token.sub; session.username = token.username; const user = await User.findOne({ _id: token.sub }); if (user) {