I am getting null object after implementing Azure Ad in an Angular application

Sandip Padhi 0 Reputation points

I am trying to implement Azure Ad authentication with MFA in an Angular application.

Login is happening but after successful login, when I check the object, I am getting as null.

In the user log, I am seeing signing happening correctly

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,940 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
18,636 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 2,150 Reputation points Microsoft Employee

    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.

    0 comments No comments