No valid session after successful login using Next.js sdk

I am writing a Next.js app using the Auth0 sdk. I followed the steps from the quickstart.

My problem is that getSession() is returning null in the login callback after a successful login. getAccessToken is throwing an AccessTokenError: The user does not have a valid session. I have checked in the auth0 user logs and they show that every login is indeed successful.

Here is the code for the callback

 import { getSession, getAccessToken } from '@auth0/nextjs-auth0';
 import { redirect } from 'next/navigation'
 
 const page = async function LoginCallback() {
     const session = await getSession(); //null
     const { accessToken } = await getAccessToken(); //AccessTokenError
 
     console.log("login callback")
     console.log(session?.user)
     console.log(accessToken)
     
     redirect("/dashboard/report");
 }
 
 export default page

I have wrapped my layout with the UserProvider

  export default async function RootLayout({
   children,
 }: Readonly<{
   children: React.ReactNode;
 }>) {
 
   
   return (
     <html lang="en">
       <UserProvider>
         <body className={inter.className}>
           <AppRouterCacheProvider>
             <ThemeProvider theme={theme}>
               {children}
             </ThemeProvider>
           </AppRouterCacheProvider>
         </body>
       </UserProvider>
     </html>
   );
}

At this point I’m at a loss for how to go about diagnosing this problem. Is there anyway to turn on verbose logging on the client side?

Thank you for your time

Did you find a solution? I’m running into a similar problem…