Skip to content

OAuth 2.0 configuration

You can configure OAuth 2.0 authorization by calling the initOAuth method.

Property nameDocker variableDescription
clientIdOAUTH_CLIENT_IDDefault clientId. MUST be a string
clientSecretOAUTH_CLIENT_SECRET🚨 Never use this parameter in your production environment. It exposes crucial security information. This feature is intended for dev/test environments only. 🚨
Default clientSecret. MUST be a string
realmOAUTH_REALMrealm query parameter (for oauth1) added to authorizationUrl and tokenUrl. MUST be a string
appNameOAUTH_APP_NAMEapplication name, displayed in authorization popup. MUST be a string
scopeSeparatorOAUTH_SCOPE_SEPARATORscope separator for passing scopes, encoded before calling, default value is a space (encoded value %20). MUST be a string
scopesOAUTH_SCOPESstring array or scope separator (i.e. space) separated string of initially selected oauth scopes, default is empty array
additionalQueryStringParamsOAUTH_ADDITIONAL_PARAMSAdditional query parameters added to authorizationUrl and tokenUrl. MUST be an object
useBasicAuthenticationWithAccessCodeGrantOAUTH_USE_BASIC_AUTHOnly activated for the accessCode flow. During the authorization_code request to the tokenUrl, pass the Client Password using the HTTP Basic Authentication scheme (Authorization header with Basic base64encode(client_id + client_secret)). The default is false
usePkceWithAuthorizationCodeGrantOAUTH_USE_PKCEOnly applies to Authorization Code flows. Proof Key for Code Exchange brings enhanced security for OAuth public clients. The default is false

Note: This option does not hide the client secret input because neither PKCE nor client secrets are replacements for each other.
const ui = SwaggerUI({...})
// Method can be called in any place after calling constructor SwaggerUIBundle
ui.initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: " ",
scopes: "openid profile",
additionalQueryStringParams: {test: "hello"},
useBasicAuthenticationWithAccessCodeGrant: true,
usePkceWithAuthorizationCodeGrant: true
})