OAuth2Client.createAuthorizationURL()
Creates a new authorization URL. This method supports both plain and S256 PKCE code challenge methods. By default, no scopes are included.
See oslo/oauth2 for a full example. For generating the state and code verifier, see generateState() and generateCodeVerifier() respectively.
Definition
function createAuthorizationURL(options?: {
state?: string;
codeChallengeMethod?: "S256" | "plain";
codeVerifier?: string;
scopes?: string[];
}): Promise<URL>;
Parameters
optionsstatecodeVerifier: Code verifier for PKCE flowcodeChallengeMethod(default:"S256"): Ignored ifcodeVerifieris undefinedscopes: An array of scopes
Example
import { generateState, generateCodeVerifier } from "oslo/oauth2";
const state = generateState();
const codeVerifier = generateCodeVerifier();
const url = await oauth2Client.createAuthorizationURL({
state,
codeVerifier,
scopes: ["profile", "openid"]
});