Hello @Sandip Padhi This could be due to a variety of reasons, and I’ll try to provide some general advice to help you troubleshoot.
Check your Redirect URI: Ensure that the redirect URI in your Azure AD app registration matches the one in your Angular application. The redirect URI is where Azure AD will return the user to your app after they have authenticated.
Verify your MSAL Configuration: Make sure that your MSAL (Microsoft Authentication Library) configuration in your Angular app is correct. This includes the client ID, authority, and other parameters.
Inspect the Token Response: After the handleRedirectPromise
method is called, inspect the token response. If the token response is null
, it could mean that the user is already logged in, and you might not need to call loginRedirect
again.
Use MSAL Guard: MSAL Guard can be used to protect your routes and ensure that only authenticated users can access them. If a user is not authenticated, MSAL Guard will automatically prompt them to authenticate.
Update Dependencies: Ensure that you’re using the latest versions of the MSAL library and other dependencies in your Angular app. Sometimes, issues can be resolved by simply updating to the latest versions.
I hope this helps you.