Skip to content

ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again.Β #8085

@giopachera

Description

@giopachera

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

2.39.0

Wrapper Library

Not Applicable

Wrapper Library Version

None

Public or Confidential Client?

Public

Description

When I initialize PublicClientApplication and call handleRedirectPromise(), I get the following error:
ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again.
This happens after redirect login or page refresh when the application is running on localhost.
Credentials and login flow work correctly on other environments (stage, production).
This issue did not happen before; the same code used to work.
I tried different combinations of Node versions and MSAL library versions, but the issue persists:

  • msal-browser 2.39.0 with Node 14;
  • msal-browser 2.39.0 with Node 20;
  • msal-browser 4.24.1 (updating the flow) with Node 20.

Error Message

ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientAuthError: openid_config_error: Could not retrieve endpoints. Check your authority and verify the .well-known/openid-configuration endpoint returns the required endpoints. Attempted to retrieve endpoints from: https://company.b2clogin.com/company.onmicrosoft.com/b2c_company_app/v2.0/.well-known/openid-configuration

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

{
auth: {
    clientId: process.env.clientId,
    authority: `https://${process.env.tenantName}.b2clogin.com/${process.env.tenantName}.onmicrosoft.com/${process.env.userFlow}`,
    knownAuthorities: [`${process.env.tenantName}.b2clogin.com`],
    redirectUri: window.location.origin,
    postLogoutRedirectUri: window.location.origin
  }
}

Relevant Code Snippets

const loginRequest = {
  scopes: ['profile']
}

const accounts = state.authInstance.getAllAccounts()
if (accounts.length > 0) {
  //Set active account in store
}

state.authInstance.addEventCallback(
  event => {
    if (event.eventType === EventType.LOGIN_SUCCESS && event.payload.account) {
      const account = event.payload.account
      //Set active account in store
    }
  },
  error => {
    console.error(error)
  }
)

state.authInstance.handleRedirectPromise()
  .then(() => {
    const account = state.authInstance.getActiveAccount()
    if (!account) {
      state.authInstance.loginRedirect(loginRequest)
    } else {
      state.authInstance.acquireTokenSilent(loginRequest)
        .then(tokenResponse => {
          //Set token in store
        })
        .catch(tokenError => {
          console.error(tokenError)
        })
    }
  })
  .catch(err => {
    console.error(err)
  })

Reproduction Steps

  1. Run the application locally and open it in the browser;
  2. Enter valid credentials on the Azure B2C login page;
  3. After successful login, the app redirects to http://localhost:8080;
  4. See that the page enters a continuous loop and fails to load properly.

Expected Behavior

After entering valid credentials on the Azure B2C login page, the app should successfully redirect to http://localhost:8080 and allow access to the application, as it did previously (before May).

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari

Regression

@azure/msal-browser 2.39.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention πŸ‘‹Awaiting response from the MSAL.js teamb2cRelated to Azure B2C library-specific issuesbug-unconfirmedA reported bug that needs to be investigated and confirmedmsal-browserRelated to msal-browser packagepublic-clientIssues regarding PublicClientApplicationsquestionCustomer is asking for a clarification, use case or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions