Hi, I developing auth by Next-Auth.js, next.js, by Auth0 (now only Google auth).
I could get access token after Auth0 callback, but payload block in access token is empty (a part of ‘n0…J’).
I can’t auth to graphql server (nest) by this access token because of above reason.
How can I get access token include payload block?
Thanks.
[after auth successful debug log]
[next-auth][debug][OAUTH_CALLBACK_RESPONSE] {
profile: {
id: 'google-oauth2|10XXXXXXXXXX,
name: 'xx',
email: 'xxx@xxx.com',
},
account: {
provider: 'auth0',
type: 'oauth',
providerAccountId: 'google-oauth2|10XXXXXXXXXXXXX',
access_token: 'e*******n0..J****zg.T_***',
[.env]
# For Next-Auth
NEXTAUTH_URL=http://localhost:4200
NEXTAUTH_SECRET=*************
# For Auth0
AUTH0_CLIENT_ID=t******************
AUTH0_CLIENT_SECRET=(set from auth0 console)
AUTH0_DOMAIN=https://my-domain.auth0.com
[nextauth].js
import NextAuth from 'next-auth';
import Auth0Provider from 'next-auth/providers/auth0';
export default NextAuth({
debug: true,
providers: [
Auth0Provider({
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
issuer: process.env.AUTH0_DOMAIN,
}),
],
secret: process.env.AUTH0_CLIENT_SECRET,
callbacks: {
async session({ session, token }) {
session.user.accessToken = token.accessToken;
session.user.id_token = token.id_token;
return session;
},
async jwt({token, account, user }) {
if (account) token.id_token = account.id_token;
if (account) token.accessToken = account.access_token;
return token
}
},
session: {
strategy: 'jwt',
maxAge: 60 * 60 * 24,
},
jwt: {
maxAge: 60 * 3,
},
});