0
votes

I have an issue with a web api returning HTTP 401 – Unauthorized when I use a Bearer Token to access it from a xamarin client. Either the iOS or UWP fail.

-This is an application that authenticates with Azure Active Directory to allow a user to login -Once successfully logged in it gets a token that in turn is added to the web api request header -The web api has its authentication turn on

The issue with azure settings https://1drv.ms/v/s!ApPhjsvemKJggpR2ax5w4wRJcY7uXQ

the code https://github.com/wleon12/XamarinForms-AAD-WebAPI.git

I cant seem to figure out what is wrong, appreciate any input or guidance

1

1 Answers

0
votes

It depends how you protect the web API.

Normally, when we protect the web API using Azure AD, we will provide the the Audience and Tenant like this code sample. So that when we send the request with the token, the web API will verify the signature of the token and the value we config.

So for the 401 issue, please check the token you acquired with the value you config for the web API project. To check the Audience, Tenant and other values in the token, you can decode it from this site.