Custom options to get an access token.

Hierarchy

  • AccessTokenRequest

Properties

afterRefresh?: AfterRefresh

When 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.

See

also the AfterRefetch hook.

Example

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,
});
};
authorizationParams?: Partial<AuthorizationParameters>

This is useful for sending custom query parameters in the body of the refresh grant request for use in rules.

refresh?: boolean

If 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.

scopes?: string[]

A list of desired scopes for your access token.