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
Goal: I have a NextJS app, that I would like to use NextAuth for authenticating uses with Google. After the user has initiated the initiated the signin I was hope to use the callback options to use the access_token from the provider (google in this case) to fetch a JWT token from my strapi API. I don't understand what I am missing, but I can seem to get the access token to be available in the JWT or Session callback. When I set DEBUG = true, I am able to see the attributes. Any help would be appreciated.
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
authorizationUrl: 'https://accounts.google.com/o/oauth2/v2/auth?prompt=consent&access_type=offline&response_type=code',
})
],
adapter: FaunaAdapter(client),
jwt: {
encryption: true,
},
session: {
strategy: "database"
},
secret: process.env.SECRET,
debug: true,
callbacks: {
async jwt({ token, _, account }) {
// Persist the OAuth access_token to the token right after signin
if (account) {
token.accessToken = account.access_token;
}
return token
},
async session({ session, token, user }) {
// Send properties to the client, like an access_token from a provider.
session.accessToken = token.accessToken;
return session
},
async redirect({url, _baseUrl}) {
if (url === '/check') {
return Promise.resolve('/')
}
return Promise.resolve('/')
}
}
});
I have removed the part where I was trying to make the call to my STRAPI backend because I first want to understand why I can't get the ACCESS TOKEN in the the session or jwt 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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Goal: I have a NextJS app, that I would like to use NextAuth for authenticating uses with Google. After the user has initiated the initiated the signin I was hope to use the callback options to use the access_token from the provider (google in this case) to fetch a JWT token from my strapi API. I don't understand what I am missing, but I can seem to get the access token to be available in the JWT or Session callback. When I set DEBUG = true, I am able to see the attributes. Any help would be appreciated.
I have removed the part where I was trying to make the call to my STRAPI backend because I first want to understand why I can't get the ACCESS TOKEN in the the session or jwt callback.
Error's I am seeing:

OR
Any help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions