MSAL.js refuses the authority with untrusted_authority
Your error
ClientConfigurationError: untrusted_authority: See https://aka.ms/msal.js.errors#untrusted_authority for details1 more line it can showFix it fast
Most common cause, 1 of 3A B2C, ADFS or other OIDC host is not in knownAuthorities
Add the host name of the authority, without the path, to knownAuthorities.
// Azure AD B2C
auth: {
clientId: '<client-id>',
authority: 'https://contoso.b2clogin.com/contoso.onmicrosoft.com/B2C_1_signupsignin',
knownAuthorities: ['contoso.b2clogin.com'],
},
// ADFS
auth: { clientId: '<client-id>', authority: 'https://adfs.contoso.com/adfs/', knownAuthorities: ['adfs.contoso.com'] },
// another OIDC provider
auth: { clientId: '<client-id>', authority: 'https://login.live.com', knownAuthorities: ['login.live.com'] },
system: { protocolMode: 'OIDC' },Short answer
untrusted_authority means MSAL.js could not confirm that your authority host is a real identity provider. Microsoft's own login hosts are trusted out of the box, but B2C tenants, ADFS servers, custom domains and other OIDC providers must be listed by host name in auth.knownAuthorities. Applies to @azure/msal-browser 5.x and @azure/msal-react 5.x.
Which cause do you have?
Log the host MSAL will check next to the list you configured, for the config and for any request that sets its own authority. An empty list is cause 1. A list that lacks that exact host is cause 2. A host that looks like Microsoft's but is not spelled like any of its login domains is cause 3.
console.log(new URL(msalConfig.auth.authority).host, msalConfig.auth.knownAuthorities);
console.log(loginRequest.authority && new URL(loginRequest.authority).host);Then find the line you see in this list and open its fix:
- 1A B2C, ADFS or other OIDC host is not in knownAuthorities
The authority is on b2clogin.com, an ADFS server or a third-party OIDC provider, and knownAuthorities is missing or an empty array - 2The listed host differs from the one MSAL is asked to use
knownAuthorities has entries, but the logged host is a custom domain or the host from a request-level authority, such as a password-reset policy - 3The Entra ID authority host is misspelled
The authority is meant to be Microsoft Entra ID, but its host is not exactly login.microsoftonline.com or another Microsoft cloud login domain
What does the error look like?
ClientConfigurationError: untrusted_authority: See https://aka.ms/msal.js.errors#untrusted_authority for detailsuntrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.
Cause 1 of 3
A B2C, ADFS or other OIDC host is not in knownAuthorities
You seeThe authority is on b2clogin.com, an ADFS server or a third-party OIDC provider, and knownAuthorities is missing or an empty array
Check
MSAL.js throws untrusted_authority for a B2C, ADFS or third-party authority because it cannot verify such a host by itself. The MSAL.js authority docs explain that B2C subdomains and ADFS domains are custom to each customer, so the library will not trust them by default and expects them in knownAuthorities. Azure AD B2C has been closed to new customers since 1 May 2025, but existing tenants keep this setup.
grep -rn "knownAuthorities\|authority:" src/Fix
Add the host name of the authority, without the path, to knownAuthorities. For an OIDC provider outside Microsoft, also set protocolMode to OIDC.
// Azure AD B2C
auth: {
clientId: '<client-id>',
authority: 'https://contoso.b2clogin.com/contoso.onmicrosoft.com/B2C_1_signupsignin',
knownAuthorities: ['contoso.b2clogin.com'],
},
// ADFS
auth: { clientId: '<client-id>', authority: 'https://adfs.contoso.com/adfs/', knownAuthorities: ['adfs.contoso.com'] },
// another OIDC provider
auth: { clientId: '<client-id>', authority: 'https://login.live.com', knownAuthorities: ['login.live.com'] },
system: { protocolMode: 'OIDC' },Verify
Call the sign-in again: the provider's login page opens and the console shows no ClientConfigurationError.
await msalInstance.loginPopup(loginRequest);Confirmed by raw.githubusercontent.com
Cause 2 of 3
The listed host differs from the one MSAL is asked to use
You seeknownAuthorities has entries, but the logged host is a custom domain or the host from a request-level authority, such as a password-reset policy
Check
untrusted_authority with a filled knownAuthorities list means none of its entries equals the authority's host. MSAL lowercases both sides and compares host names, ignoring any path, so a custom sign-in domain such as login.contoso.com does not match contoso.b2clogin.com. An authority passed in a login or acquireToken request also overrides the one in the config, and its host must be listed too.
grep -rn "authority:" src/Fix
List every host your app signs in through: the default B2C host, any custom domain, and the hosts of authorities passed per request.
auth: {
clientId: '<client-id>',
authority: 'https://login.contoso.com/contoso.onmicrosoft.com/B2C_1_signupsignin',
knownAuthorities: ['login.contoso.com', 'contoso.b2clogin.com'],
},
const resetRequest = {
scopes: ['openid'],
authority: 'https://login.contoso.com/contoso.onmicrosoft.com/B2C_1_passwordreset',
};Verify
Run both the normal sign-in and the flow with the request-level authority; neither throws.
await msalInstance.loginRedirect(resetRequest);Confirmed by raw.githubusercontent.com
Cause 3 of 3
The Entra ID authority host is misspelled
You seeThe authority is meant to be Microsoft Entra ID, but its host is not exactly login.microsoftonline.com or another Microsoft cloud login domain
Check
For Entra ID, MSAL first checks a built-in list of Microsoft login hosts, such as login.microsoftonline.com, login.microsoftonline.us and login.chinacloudapi.cn, and only then asks Microsoft's instance discovery endpoint. A misspelled host is in neither place, so discovery cannot resolve it and MSAL stops with untrusted_authority.
console.log(new URL(msalConfig.auth.authority).host)Fix
Copy the authority from the Endpoints panel of the app registration in the Azure portal and keep only the host and tenant part.
auth: {
clientId: '<client-id>',
authority: 'https://login.microsoftonline.com/<tenant-id>',
},Verify
Sign-in opens the Microsoft login page, and the logged host matches the registration's endpoint host.
await msalInstance.loginPopup({ scopes: ['User.Read'] });Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Build knownAuthorities from the same environment variables as the authority URLs, so a new domain or policy cannot be added to one and forgotten in the other.
- Keep each B2C policy's authority in one config module and import it into requests instead of typing URLs in components.
- Add a smoke test that calls loginPopup against the staging tenant after every change to the MSAL config.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, QistLock, Taskvare.