nextjs-auth0
nextjs-auth0 copied to clipboard
Better support for refresh tokens
Describe the problem you'd like to have solved
We now have the capability to store a refresh_token in the session using storeRefreshToken. However, as a developer I currently need to do a lot of heavy lifting to put this to good use:
- I use the
access_token - When the API I'm calling returns a
401, I can assume that the token is expired and use the refresh token instead. - I need to perform the refresh token exchange myself
- I don't really have a capability to update the access_token in the session
Describe the ideal solution
Ideally I would be able to retrieve an access token from the session and everything is handled for me. If the token is valid, return that. If the token is missing a scope, return null. If the token is for an other audience, return null. If the token is expired, renew it, ...
const { user } = await auth0.getSession(req, res);
const accessToken = auth0.getAccessToken({
scope: 'read:calendar',
audience: 'https://myapp.com/api'
});
Any news about this ? Is there a way to update the session with the new access_token generated with a refresh_token ?
Released in v0.8.0 👋