Configuration Options

July 1, 2026 ยท View on GitHub

Before you start here, make sure you understand how to initialize an app object.

The MSAL library has a set of configuration options that can be used to customize the behavior of your authentication flows. These options can be set either in the constructor of the PublicClientApplication object or as part of the request APIs. Here we describe the configuration object that can be passed into the PublicClientApplication constructor.

Using the config object

The configuration object has the following structure, and can be passed into the PublicClientApplication constructor. The only required config parameter is the client ID of the application. Everything else is optional, but may be required depending on your tenant and application model.

const msalConfig = {
    auth: {
        clientId: "enter_client_id_here",
        authority: "https://login.microsoftonline.com/common",
        knownAuthorities: [],
        cloudDiscoveryMetadata: "",
        redirectUri: "enter_redirect_uri_here",
        postLogoutRedirectUri: "enter_postlogout_uri_here",
        navigateToLoginRequestUrl: true,
        clientCapabilities: ["CP1"],
    },
    cache: {
        cacheLocation: "sessionStorage",
    },
    system: {
        loggerOptions: {
            loggerCallback: (
                level: LogLevel,
                message: string,
                containsPii: boolean
            ): void => {
                if (containsPii) {
                    return;
                }
                switch (level) {
                    case LogLevel.Error:
                        console.error(message);
                        return;
                    case LogLevel.Info:
                        console.info(message);
                        return;
                    case LogLevel.Verbose:
                        console.debug(message);
                        return;
                    case LogLevel.Warning:
                        console.warn(message);
                        return;
                }
            },
            piiLoggingEnabled: false,
        },
        windowHashTimeout: 60000,
        iframeHashTimeout: 6000,
        loadFrameTimeout: 0,
        protocolMode: "AAD",
        serverTelemetryEnabled: false,
    },
    telemetry: {
        application: {
            appName: "My Application",
            appVersion: "1.0.0",
        },
    },
};

const msalInstance = new PublicClientApplication(msalConfig);

Configuration Options

Auth Config Options

OptionDescriptionFormatDefault Value
clientIdApp ID of your application. Can be found in your portal registration.UUID/GUIDNone. This parameter is required in order for MSAL to perform any actions.
authorityURI of the tenant to authenticate and authorize with. Usually takes the form of https://{uri}/{tenantid} (see Authority)String in URI format with tenant - https://{uri}/{tenantid}https://login.microsoftonline.com/common
knownAuthoritiesAn array of known authority URIs. Used in B2C and CIAM scenarios. For CIAM with Entra External ID, include the GUID-based issuer host if it differs from the authority host (see Authority - CIAM).Array of strings in URI formatEmpty array []
cloudDiscoveryMetadataA string containing the cloud discovery response. Used in AAD scenarios. See Performance for more infostringEmpty string ""
authorityMetadataA string containing the .well-known/openid-configuration endpoint response. See Performance for more infostringEmpty string ""
redirectUriURI where the authorization code response is sent back to. Whatever location is specified here must have the MSAL library available to handle the response.String in absolute or relative URI formatLogin request page (window.location.href of page which made auth request)
postLogoutRedirectUriURI that is redirected to after a logout() call is made.String in absolute or relative URI format. Pass null to disable post logout redirect.Login request page (window.location.href of page which made auth request)
popupRelayUriURI of a first-party, top-level "popup-relay" page used to acquire tokens (and log out) interactively from inside a cross-origin iframe, where third-party storage partitioning and COOP would otherwise break the popup flow. When set, acquireTokenPopup/logoutPopup open this page top-level and relay the flow through it. Must be same-origin as the app. See Popup relay for cross-origin iframes.String in absolute or relative (same-origin) URI format.Empty string "" (disabled)
navigateToLoginRequestUrlIf true, will navigate back to the original request location before processing the authorization code response. If the redirectUri is the same as the original request location, this flag should be set to false.booleantrue
clientCapabilitiesArray of capabilities to be added to all network requests as part of the xms_cc claims request (see: Client capability in MSAL)Array of strings[]
azureCloudOptionsA defined set of azure cloud options for developers to default to their specific cloud authorities, for specific clouds supported please refer to the AzureCloudInstanceAzureCloudOptionsAzureCloudInstance.None
onRedirectNavigateA callback that will be passed the url that MSAL will navigate to in redirect flows. Returning false in the callback will stop navigation.`(url: string) => booleanvoid`
instanceAwareA flag of whether the STS will send back additional parameters to specify where the tokens should be retrieved from.booleanfalse
isMcpIf true, a resource parameter is required on all token requests. Used for MCP flows. See MCP documentation for more details.booleanfalse

popupRelayUri lets acquireTokenPopup (and logoutPopup) work when your app runs inside an untrusted, cross-origin iframe โ€” a context where third-party storage partitioning and COOP normally break the popup flow. When set, MSAL opens the relay page top-level (on your own origin) instead of navigating the popup straight to the identity provider, and that page relays the response back to the embedded frame. No tokens, PKCE verifier, or EAR key cross the window boundary.

Setup:

  • Host a same-origin page at popupRelayUri that calls runPopupRelay() from the @azure/msal-browser/popup-relay sub-export. It opens the IdP child popup, so call it from a user gesture (e.g. a "Continue" button click) so popup blockers don't block it.
  • Point your redirectUri (and, for logout, postLogoutRedirectUri) at a page that calls broadcastResponseToMainFrame() from the @azure/msal-browser/redirect-bridge sub-export.

Caveats:

  • The relay is a browser SPA-only mechanism (PublicClientApplication in @azure/msal-browser). It brokers the standard interactive popup auth-code flow through a same-origin page and is not intended for native app, platform broker (WAM), Nested App Auth, or confidential-client / server-side scenarios.
  • popupRelayUri must resolve to the same origin as the app; a cross-origin value throws popup_relay_unsupported_flow with sub-error popup_relay_cross_origin (see errors).
  • The relay page opens the IdP popup, so it must be triggered by a user gesture.
  • The auth-code (GET), form_post, and EAR response modes are all supported.

Cache Config Options

OptionDescriptionFormatDefault Value
cacheLocationLocation of token cache in browser.String value that must be one of the following: "sessionStorage", "localStorage", "memoryStorage"sessionStorage

See Caching in MSAL for more.

System Config Options

OptionDescriptionFormatDefault Value
loggerOptionsConfig object for logger.See below.See below.
navigatePopupsSets whether popups are opened and navigated to later. By default, this flag is set to true. When set to true, blank popups are opened and navigates to login domain. When set to false, popups are opened directly to the login domain. This can be set to false for scenarios where about:blank is not supported, e.g. desktop apps or progressive web apps.booleantrue
allowRedirectInIframeBy default, MSAL will not allow redirect operations to be initiated when the application is inside an iframe. Set this flag to true to remove this check.booleanfalse
cryptoOptionsConfig object for crypto operations in the browser.See belowSee below
popupBridgeTimeoutTimeout in milliseconds to wait for the popup to send its response via BroadcastChannel. If the user closes the popup without completing authentication, loginPopup or acquireTokenPopup will reject with a timed_out error after this timeout. See Popup closure detection.integer (milliseconds)60000
iframeBridgeTimeoutTimeout in milliseconds to wait for a hidden iframe to send its response via BroadcastChannel during silent token acquisition (ssoSilent, acquireTokenSilent). If the iframe does not respond within this time, the call will reject with a timed_out error.integer (milliseconds)10000
protocolModeEnum representing the protocol mode to use. If "AAD", will function on the OIDC-compliant AAD v2 endpoints; if "OIDC", will function on other OIDC-compliant endpoints.string"AAD"
serverTelemetryEnabledEnables MSER server telemetry headers and browser cache writes for failed requests. When false, MSAL does not send MSER headers and does not persist server telemetry data to browser storage. This option is deprecated and will be removed in a future release.booleanfalse

Logger Config Options

OptionDescriptionFormatDefault Value
loggerCallbackCallback function which handles the logging of MSAL statements.Function - loggerCallback: (level: LogLevel, message: string, containsPii: boolean): voidSee above.
piiLoggingEnabledIf true, personally identifiable information (PII) is included in logs.booleanfalse

Crypto Config Options

OptionDescriptionFormatDefault Value
useMsrCryptoWhether to use MSR Crypto if available in the browser (and other crypto interfaces are not available).booleanfalse
entropyCryptographically strong random values used to seed MSR Crypto (e.g. crypto.randomBytes(48) from Node). 48 bits of entropy is recommended. Required if useMsrCrypto is enabled.Uint8Arrayundefined

Telemetry Config Options

OptionDescriptionFormatDefault Value
applicationTelemetry options for applications using MSAL.jsSee belowSee below
clientTelemetry performance client instanceIPerformanceClientStubPerformanceClient

Application Telemetry

OptionDescriptionFormatDefault Value
appNameUnique string name of an applicationstringEmpty string ""
appVersionVersion of the application using MSALstringEmpty string ""