401 UnAuthorized to get user profile from Graph API

Rajarathinam Balasubramaniya 1 Reputation point
2022-08-30T07:42:17.74+00:00

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

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

1 answer

Sort by: Most helpful
  1. 2022-08-31T19:48:21.483+00:00

    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.

    0 comments No comments