How to create a session using @auth0/nextjs-auth0 from access_token and refresh_token

  • Which SDK this is regarding: @auth0/nextjs-auth0
  • SDK Version: 0.16.0
  • Platform Version: e.g. Next.js v10.1.3, Node v15.7.0

I’m trying to silently create an Auth0 profile and log in my users when they click a “magic link” using a specific Magic Link database connection. I’m not here to discuss if that is a good idea (happy to do that over a beer/coffee another day), but what I want for our users to be “logged in”.

The app is a Next.js app and I’m using the @auth0/nextjs-auth0 sdk.

So far in my flow I’ve used the management API such that I know have the user’s:

username
password (a nonce)
access_token
refresh_token

I understand that technically they are “logged in” because I have an access_token and refresh_token, but my question is how do I save these so that the @auth0/nextjs-auth0 sdk sees them as being logged in with an active session.

i.e. so that when I redirect them to a page and get the session, that it shows their session information.

Alternatively, is there a better way to silently create a profile and log a user in to a Next.js app?

2 Likes

Did you somehow manage to solve this?