401 UnAuthorized to get user profile from Graph API


The application was created by me using Angular 8 and the msal-angular 0.1.4 library. With very little response, I can authenticate and get the response to operate properly. My request has changed, and I now need to obtain the user profile and other data, such as an access token. The library for my current project has been upgraded. I can retrieve the data because I inserted the provider as MsalInterceptor in app.module.ts. But that bothers me because my application uses both app login (DB Validation) and Azure SSO for login. If I add MsalInterceptor to the app.module.ts file and log in as the database user, an error occurs. "ClientAuthError" is the error code. Whether I log in as a DB user or an app user, the error associated with UserAgentAppliation has been executed.

Error is : Failed to load resource: the server responded with a status of 401 (Unauthorized)

If i move MsalInterceptor to other module

Please help

Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
13,488 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
843 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla (MSFT) 16,686 Reputation points Microsoft Employee

    Hello @Rajarathinam Balasubramaniya and thanks for reaching out. MsalInterceptor is provided for your convenience and may not fit all use cases, you're welcome to write down your own interceptor and/or inherit from the default one so that pre or post processing is added to the token acquire. E.g. When calling the Graph me endpoint but not yet logged as an Azure AD user (but a DB user) you can drop the call or require Azure AD authentication.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and complete the quality survey so that others can find a solution.