How to resolve 401 Unauthorized Error for API calls from UWP application using MSAL token

Sushma Sharani 0 Reputation points
2023-07-31T13:08:04.71+00:00

We have an UWP application for which we are using ADAL Authentication process . But we are migrating it to MSAL. We have followed the code implementation for our application as suggested in the below link

https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-net-migration-public-client?tabs=interactive

Post our authentication , we are calling web APIs which are hosted in Azure APIM and the code development is handled in a different Project.

While calling the API , we are passing the token with "Authorization header through the HttpClient" object and in Response we are getting 401 "Unauthorized".

Microsoft Security Microsoft Entra Microsoft Entra ID
Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-07-31T17:43:35.18+00:00

    if the app is displaying the login dialog with no errors, then most likely you have not defined a scope for api access. you api registration needs a scope defined for access, and your login should include this scope.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.