Optional
afterWhen the access token request refreshes the tokens using the refresh grant the session is updated with new tokens. Use this to modify the session after it is refreshed. Usually used to keep updates in sync with the AfterCallback hook.
also the AfterRefetch hook.
Modify the session after refresh
// pages/api/my-handler.js
import { getAccessToken } from '@auth0/nextjs-auth0';
const afterRefresh = (req, res, session) => {
session.user.customProperty = 'foo';
delete session.idToken;
return session;
};
export default async function MyHandler(req, res) {
const accessToken = await getAccessToken(req, res, {
refresh: true,
afterRefresh,
});
};
Optional
authorizationThis is useful for sending custom query parameters in the body of the refresh grant request for use in rules.
Optional
refreshIf set to true
, a new access token will be requested with the refresh token grant, regardless of whether
the access token has expired or not.
IMPORTANT You need to request the offline_access
scope on login to get a refresh token
from Auth0.
Optional
scopesA list of desired scopes for your access token.
Custom options to get an access token.