Configuration Options

March 10, 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.

In this document:

Usage

The configuration object 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 authentication flow, tenant and application model.

Configuration object with all supported parameters is as below:


// Call back APIs which automatically write and read into a .json file - example implementation
const beforeCacheAccess = async (cacheContext) => {
    cacheContext.tokenCache.deserialize(await fs.readFile(cachePath, "utf-8"));
};

const afterCacheAccess = async (cacheContext) => {
    if(cacheContext.cacheHasChanged){
        await fs.writeFile(cachePath, cacheContext.tokenCache.serialize());
    }
};

// Cache Plugin
const cachePlugin = {
    beforeCacheAccess,
    afterCacheAccess
};;

const msalConfig = {
    auth: {
        clientId: "enter_client_id_here",
        authority: "https://login.microsoftonline.com/common",
        knownAuthorities: [],
        cloudDiscoveryMetadata: "",
        azureCloudOptions: {
            azureCloudInstance: "enter_AzureCloudInstance_here" // AzureCloudInstance enum is exported as a "type",
            tenant: "enter_tenant_info" // defaults to "common"
        }
    },
    cache: {
        cachePlugin // your implementation of cache plugin
    },
    system: {
        loggerOptions: {
            loggerCallback(loglevel, message, containsPii) {
                console.log(message);
            },
            piiLoggingEnabled: false,
            logLevel: msal.LogLevel.Verbose,
        },
    }
}

const msalInstance = new PublicClientApplication(msalConfig);

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 URIs that are known to be valid. Used in B2C scenarios.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 ""
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
isMcpIf true, a resource parameter is required on all token requests. Used for MCP flows. See MCP documentation for more details.booleanfalse

Cache Config Options

OptionDescriptionFormatDefault Value
cachePluginCache plugin with call backs to reading and writing into the cache persistence (see also: caching)ICachePluginnull

Broker Config Options

OptionDescriptionFormatDefault Value
nativeBrokerPluginBroker plugin for acquiring tokens via a native token broker (see also: brokering)INativeBrokerPluginnull

System Config Options

OptionDescriptionFormatDefault Value
loggerOptionsConfig object for logger.See below.See below.
NetworkClientCustom HTTP implementationINetworkModuleHttpClient.ts
disableInternalRetriesA flag that disables MSALJS's built-in retry policies, allowing the app developer to specify their own retry policy. Currently, only Managed Identity flows have a retry policy.booleanboolean false
protocolModeEnum representing the protocol mode to use. If "AAD", will function on the AAD v2 endpoints; if "OIDC", will function on OIDC-compliant endpoints.string"AAD"

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

Telemetry Config Options

OptionDescriptionFormatDefault Value
applicationTelemetry options for applications using MSAL.jsSee belowSee below

Application Telemetry

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

Next Steps

Proceed to understand the public APIs provided by msal-node for acquiring tokens here