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
but above Session log prints { user: { name: undefined, email: undefined, image: undefined } } only
noticed that /api/auth/callback/session is not getting called.
Since i am using SSR component read that no need of SessionProvider.
where do i fix to get the accesstoken and refreshtoken
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
-
i configured [..nextauth].ts
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
export default NextAuth({
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {},
authorize: async (credentials: any) => {
console.log(credentials)
return credentials ? { id: 'user', ...credentials } : null;
},
],
callbacks: {
async jwt({ token, user }: any) {
console.log("my user", user)
if (user) {
token.accessToken = user.accessToken;
token.refreshToken = user.refreshToken;
}
return token;
},
async session({ session, token, user }: any) {
session.user.name = "sibin";
session.accessToken = token.accessToken;
session.refreshToken = token.refreshToken;
console.log("my session", session)
return session;
},
},
secret: process.env.NEXTAUTH_SECRET,
});
and on successfull external API login, i just calling signIn credentials
const result = await signIn('credentials', {
redirect: false,
accessToken: responseData[0].AccessToken,
refreshToken: responseData[0].RefreshToken,
});
if (result?.error) {
console.error('SignIn Error:', result.error);
return;
}
and in my SSR component i am calling
import { getServerSession } from "next-auth/next";
import Nextauth from "@/pages/api/auth/[...nextauth]";
import MyProfile from "./MyProfile";
const Page = async () => {
const session = await getServerSession(Nextauth);
console.log("Session log:", session);
return (
<>
</>
);
};
export default Page;
but above Session log prints { user: { name: undefined, email: undefined, image: undefined } } only
noticed that /api/auth/callback/session is not getting called.
Since i am using SSR component read that no need of SessionProvider.
where do i fix to get the accesstoken and refreshtoken
Beta Was this translation helpful? Give feedback.
All reactions