question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix for multiple reload of application

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.15.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.0.4

Description

Let’s say, our redirectURI is configured to - http://localhost:4200 and we’re kicking the Authentication (by MSALGuard) in the route - http://localhost:4200/myprofile and we set the option - “navigateToLoginRequestUrl”: true

Now, we see the application loads twice -

  1. After redirecting
  2. It’s navigating to the desired route.

As per this article, this is expected - https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/performance.md#how-to-configure-azuremsal-angular-to-use-your-routers-navigate-function-for-client-side-navigation

Is there any fix available for this? I mean use the Angular Router instead of window.location to avoid the second reload of the application

MSAL Configuration

auth: {
      authority: 'https://login.microsoftonline.com/xxx-xxx-xxx/',
      clientId: 'xxx-xxx-xxx-xxxx-xxx',
      redirectUri: 'http://localhost:4200',
      postLogoutRedirectUri: 'xxxx-xxx-xxx',
      navigateToLoginRequestUrl: true
    },
    cache: {
      cacheLocation: 'sessionStorage'
    },

Relevant Code Snippets

No response

Identity Provider

Azure AD / MSA

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jasonnuttercommented, Apr 6, 2022

@roopeshreddy If the provided navigation behavior does not suite your needs, you can implement your own.

For MSAL Angular, you can provide this by calling this.msalService.instance.setNavigationClient(navigationClient).

0reactions
roopeshreddycommented, Apr 13, 2022

Thanks @jasonnutter This helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Application reload - Unity Forum
Application.reload causes a major issue while debugging. ... This happens across multiple unity projects and even new blank projects.
Read more >
Spring MVC and Application Context multiple refresh attempts
This is a 2 part answer. I have found to one part which comprises of the problem when we try to refresh context...
Read more >
Having already turned off “Background App Refresh”, how do I ...
Scroll to the top of the page you are on, then pull down and release. It will bounce and refresh. This is how...
Read more >
How to reload an application imperatively? · Issue #388 - GitHub
Hi, I have two applications: a root app with header, routing and auth management with "()=>true" activation function, it renders a div with ......
Read more >
Restart or Reload the Application - Oracle Help Center
Click Reload to reload the application to fix the issue with a simple reload. If that doesn't work, click Clear the cache and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found