Closed
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
In our project, we have to get idToken for token trading.
This is v3 code. As you can see, I could get idToken from session
object.
import { NextResponse } from 'next/server'
import auth0 from '@/config/auth0'
export const GET = auth0.withApiAuthRequired(async function GET(req) {
const res = new NextResponse()
try {
const session = await auth0.getSession(req, res)
const user = session?.user
if (!user?.email_verified)
return NextResponse.json(
{ error: 'email is not verified' },
{ status: 400 },
)
return NextResponse.json(
{ idToken: session?.idToken, user: session?.user },
res,
)
} catch (error: any) {
return NextResponse.json(
{ error: error.message },
{ status: error.status || 500 },
)
}
})
But idToken doesn't exist in the session
object of v4.
import { Auth0Client } from '@auth0/nextjs-auth0/server'
import { BASE_URL } from '@/constants/constants'
export const auth0 = new Auth0Client({
appBaseUrl: BASE_URL,
authorizationParameters: {
scope: 'openid profile email read:products offline_access',
},
})
Already openid
is added on scope.
Help me pls.
Reproduction
const session = await auth0.getSession()
console.log(session?.idToken)
// undefined
I think, it's enough to explain.
Additional context
No response
nextjs-auth0 version
4.0.0-beta.9
Next.js version
15.0.4
Node.js version
v22.11.0
Metadata
Metadata
Assignees
Labels
No labels