Skip to content

generateRandomToken()

Generate a secure random token. This token is used to create random strings for the state and code_verifier parameters in the OAuth2 Authorization Code flow.

Syntax

generateRandomToken();

Parameters

NONE

Returns

string;

Example Usage

const blankSession = createBlankSession();
const state = generateRandomToken();
cookies().set("google_oauth_state", state, blankSession.options);

See Also