Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msal AADB2C90085 on redirect after custom policy flow #6389

Closed
adnan-ashfaq opened this issue Aug 24, 2023 · 22 comments
Closed

Msal AADB2C90085 on redirect after custom policy flow #6389

adnan-ashfaq opened this issue Aug 24, 2023 · 22 comments
Assignees
Labels
b2c Related to Azure B2C library-specific issues msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@adnan-ashfaq
Copy link

adnan-ashfaq commented Aug 24, 2023

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

2.28.2

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.4.2

Public or Confidential Client?

Public

Description

I am implementing B2c custom MFA and PasswordRest flow in our angular app. However, after the flow is completed the msal is appending http with the redirect url. For instance if the redirect url is www.abc.com, after redirect it's www.abc.com/https:. In the browser console I get the following errors

POST https://qhrdqab2cmedeo.b2clogin.com/qhrdqab2cmedeo.onmicrosoft.com/b2c_1a_signup_signin/oauth2/v2.0/token 400 (Bad Request)
ServerError: invalid_grant: undefined - [undefined]: AADB2C90085: The service has encountered an internal error. Please reauthenticate and try again.
@azure/[email protected] : Error - Guard - error while logging in, unable to activate

MSAL Configuration

{
    auth: {
      clientId: config.clientId,
      authority: config.authorities.signUpSignIn,
      redirectUri: window.origin,
      postLogoutRedirectUri: window.origin,
      knownAuthorities: [config.authorityDomain]
    },
    cache: {
      cacheLocation: BrowserCacheLocation.LocalStorage,
      storeAuthStateInCookie: false
    },
    system: {
      loggerOptions: {
        // eslint-disable-next-line ban/ban, no-console
        loggerCallback: (level, message) => console.log(message),
        logLevel: config.logLevel,
        piiLoggingEnabled: false
      }
    }
  }

export function b2cGuardFactory(): MsalGuardConfiguration {
  return {
    interactionType: InteractionType.Redirect,
    loginFailedRoute: `${window.origin}/error/B2C_USER_LOGIN_FAILED/1`
  };
}

Relevant Code Snippets

init() {
  // setup msal to use router instead of setting window.location
    const customNavigationClient = new MsalCustomNavigationClient(this.authService, this.router, this.location);
    this.authService.instance.setNavigationClient(customNavigationClient);

    this.userFacade.userPermissions$
      .pipe(
        map(userPermission => !!this.b2cConfig && !!userPermission?.b2c_login)
      )
      .subscribe((flag: boolean) => this._enabledSubject$.next(flag));

    this.msalBroadcastService.inProgress$
      .pipe(
        filter((status: InteractionStatus) => status === InteractionStatus.None),
        takeUntil(this.ngUnsubscribe)
      )
      .subscribe(() => {
        this.checkAndSetActiveAccount();
      });

    // listen for msal events
    this.msalBroadcastService.msalSubject$.subscribe((event: EventMessage) => {
      if (event.error) {
        if (event.error.message?.indexOf('AADB2C90091') > -1) {
          this.window.location.replace('/settings');
        } else {
          console.error(event.error);
        }
      }
    });
  }

mfaSetUp() {
    // Redirect user to MFA policy
    this.authService.loginRedirect({
      extraQueryParameters: {
        p: 'B2C_1A_MFAEDIT'
      },
      scopes: OIDC_DEFAULT_SCOPES,
    });
  }

Identity Provider

Azure B2C Custom Policy

Source

Internal (Microsoft)

@adnan-ashfaq adnan-ashfaq added the question Customer is asking for a clarification, use case or information. label Aug 24, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Aug 24, 2023
@github-actions github-actions bot added b2c Related to Azure B2C library-specific issues msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels Aug 24, 2023
@lalimasharda
Copy link
Contributor

Hey @adnan-ashfaq , can you share trace level logs for this issue by setting the logLevel to Trace? Thanks!

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Aug 25, 2023
@lalimasharda
Copy link
Contributor

@adnan-ashfaq Can you also please share your network trace on my email?

@adnan-ashfaq
Copy link
Author

@adnan-ashfaq Can you also please share your network trace on my email?

Just Sent. Can you confirm you've received it?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Aug 25, 2023
@lalimasharda
Copy link
Contributor

I received the logs but not the network trace!

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Aug 25, 2023
@adnan-ashfaq
Copy link
Author

adnan-ashfaq commented Aug 25, 2023

I received the logs but not the network trace!

Just sent them.

It says file too big. Rejected from your server.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Aug 25, 2023
@adnan-ashfaq
Copy link
Author

adnan-ashfaq commented Aug 25, 2023 via email

@lalimasharda
Copy link
Contributor

Hey @adnan-ashfaq , the network trace you shared does not show the /authorize call. Can you please collect another trace and make sure it contains the /authorize and /token request & response? Also, can you please double check your code to see if you have a custom method for building a redirect URI somewhere and if it is generating the correct redirect URI? I do not see anything wrong with the redirect URI in your request to /token call.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Aug 28, 2023
@adnan-ashfaq
Copy link
Author

adnan-ashfaq commented Aug 28, 2023

Hey @lalimasharda I have just sent the complete Network log from when user sign-in to completing the flow and redirecting to the url. And yes, I have confirmed we do not have any custom method the redirect uri.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Aug 28, 2023
@adnan-ashfaq
Copy link
Author

Hi @lalimasharda @sameerag , any update on the issue?

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

5 similar comments
@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@adnan-ashfaq
Copy link
Author

Hi, Any update on the issue?

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@adnan-ashfaq
Copy link
Author

@sameerag Waiting for update on the issue.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

1 similar comment
@microsoft-github-policy-service
Copy link
Contributor

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @sameerag please follow up.

@sameerag
Copy link
Member

Closing as this is a stale issue. If the issue still persist, please raise a new issue and preferably on the latest MSAL JS version.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs: Attention 👋 Awaiting response from the MSAL.js team label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b2c Related to Azure B2C library-specific issues msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

3 participants