I have an ASP.Net Web API 2 on which I implemented the following security: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-devquickstarts-webapi-dotnet
It worked, I can't access the controllers except if I remove the [Authorize] attribute.
Now, I have a logged in user in a Xamarin app. The user is logged in via MSAL authentication which works fine too. Very basic implementation :
var authenticationResult = await App.IdentityClientApp.AcquireTokenSilentAsync(App.ClientScope);
var token = authenticationResult.Token;
Now, I want to access the web API by giving the MSAL authentication token in the DefaultRequestHeaders with something like this :
this.httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
Is there anyway this is possible ? How can I use this token to make my user consume my web API ?
Thank you !