Function: buildAuthorizationUrl()

May 28, 2025 ยท View on GitHub

๐Ÿ’— Help the project

Support from the community to continue maintaining and improving this module is welcome. If you find the module useful, please consider supporting the project by becoming a sponsor.


โ–ธ buildAuthorizationUrl(config, parameters): URL

Returns a URL to redirect the user-agent to, in order to request authorization at the Authorization Server

Note


When used, PKCE code challenge, state, and nonce parameter values must always be random and be tied to the user-agent.

Parameters

ParameterTypeDescription
configConfiguration-
parametersRecord<string, string> | URLSearchParamsAuthorization request parameters that will be included in the URL.searchParams

Returns

URL

URL Instance with URL.searchParams including client_id, response_type, and all parameters from the parameters argument

Example

let config!: client.Configuration
let redirect_uri!: string
let scope!: string

// these must be unique for every single authorization request
let code_verifier = client.randomPKCECodeVerifier()
let code_challenge =
  await client.calculatePKCECodeChallenge(code_verifier)

let redirectTo = client.buildAuthorizationUrl(config, {
  redirect_uri,
  scope,
  code_challenge,
  code_challenge_method: 'S256',
})
// redirect now