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 3.0 not returning accounts in Angular 17 after upgrading from 2.16.0 #7105

Closed
2 tasks
virendra05 opened this issue May 16, 2024 · 2 comments
Closed
2 tasks
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed confidential-client Issues regarding ConfidentialClientApplications msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@virendra05
Copy link

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

None

Public or Confidential Client?

Public, Confidential

Description

I recently upgraded @azure/msal-angular and @azure/msal-browser from version 2.16.0 to 3.0.0 in my Angular 17 project. Since the upgrade, I am unable to retrieve user accounts using this.authService.instance.getAllAccounts(), which now returns an empty array

import { MsalService, MsalBroadcastService, MSAL_GUARD_CONFIG, MsalGuardConfiguration } from '@azure/msal-angular';

constructor(
  @Inject(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration,
  private authService: MsalService, private msalBroadcastService: MsalBroadcastService) {}



 async ngOnInit() {
    this.msalBroadcastService.inProgress$
    .pipe(
      filter((status: InteractionStatus) => status === InteractionStatus.None),
      takeUntil(this._destroying$)
    )
    .subscribe(() => {
      this.setLoginDisplay();
    }, (error) => {
      this.isLoading = false;
    });
  }
  
  async setLoginDisplay() {
  if (!this.localAuthService.isLogin) {
    this.loginDisplay = this.authService.instance.getAllAccounts().length > 0;
    if (this.loginDisplay) {
      const data = this.authService.instance.getAllAccounts()[0];
      // Further processing...
    }
  }
}

No errors appear in the console, and the configurations and initializations appear to be unchanged besides the library upgrade. I suspect this might be a lifecycle or configuration issue with MSAL 3.0 in Angular 17. Has anyone encountered a similar problem or knows of any breaking changes in MSAL 3.0 that could affect account retrieval?

Error Message

No response

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

export const msalConfig: Configuration = {
    auth: signinsignupBrowserAuthOptions,
    cache: cacheOptions,
    system: browserSystemOptions

}


export const signinsignupBrowserAuthOptions = {
    clientId: ClientId,
    authority: authority,
    knownAuthorities: authorityDomain,
    redirectUri: '/',
    postLogoutRedirectUri: '/'
  }

  export const cacheOptions = {
    cacheLocation: BrowserCacheLocation.LocalStorage,
    storeAuthStateInCookie: isIE,
  }
  export const browserSystemOptions = {
    loggerOptions: {
      loggerCallback,
      logLevel: LogLevel.Info,
      piiLoggingEnabled: false
    }
  }

Relevant Code Snippets

shared in description

Reproduction Steps

Upgrade from Angular 13 to Angular 17 and add above shared in App-component.ts

Expected Behavior

Should get this.authService.instance.getAllAccounts() data

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari

Regression

No response

Source

Internal (Microsoft)

@virendra05 virendra05 added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels May 16, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label May 16, 2024
@github-actions github-actions bot added confidential-client Issues regarding ConfidentialClientApplications msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels May 16, 2024
@hectormmg
Copy link
Member

@virendra05 there are some issues with account in early minor versions of v3. Please try the latest minor/patch version and see if your problem persists.

@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 May 21, 2024
Copy link
Contributor

@virendra05 This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

@microsoft-github-policy-service microsoft-github-policy-service bot added the no-issue-activity Issue author has not responded in 5 days label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed confidential-client Issues regarding ConfidentialClientApplications msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Author Feedback Awaiting response from issue author no-issue-activity Issue author has not responded in 5 days 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

2 participants