Custom OIDC provider and opaque accessToken expiration #3267
-
Question 💬Hi! We are using Next.JS with Next-Auth for the frontend and a .NET Core Web API for the backend. Now our problem is, that the OIDC accessToken is only valid for 10 minutes and Next-Auth seems not to check if this is still valid. Our backend will give us an 401 error like this. How should the correct handling for a case like this be? Best regards, How to reproduce ☕️can't really say Contributing 🙌🏽No, I am afraid I cannot help regarding this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Token rotation is not currently supported built-in, but it can be done in userland. 10 minutes might be a bit aggressive but probably depends on your use case. To work around this now, your provider will need to give back a We've done this in production already. https://next-auth.js.org/tutorials/refresh-token-rotation This should give you an idea. |
Beta Was this translation helpful? Give feedback.
Token rotation is not currently supported built-in, but it can be done in userland.
10 minutes might be a bit aggressive but probably depends on your use case.
To work around this now, your provider will need to give back a
refresh_token
, and the lifetime of theaccess_token
. With those, you can create the logic that will refetch the token when it is near being expired.We've done this in production already.
https://next-auth.js.org/tutorials/refresh-token-rotation This should give you an idea.