I have a Blazor Web app (Server Side) that uses openid and roles (JWT). Everything works fine no problem with that. (still using .net Core 6.0) I am using Microsoft Tokens.
However besides beeing a web app this web app is also exposing a couple of API’s.
There is no problem with that either, everything works as expected.
I need to call one of the api’s from a Function App. The Function App is using EasyAuth. The Website itself is not using easy auth.
In the function app i get a bearer token for the managed identity. I can see in the JWT token that the managed identity is in the correct role. I us ethe following code to get the token.
private static async Task<string> GetTokenForResourceScopeFromIdentity(string resourceScope)
{
ManagedIdentityCredential credentials = new ManagedIdentityCredential(ManagedIdentity_Id);
var managedIdentityToken = credentials.GetToken(new TokenRequestContext(new string[] { $"{resourceScope}" }));
return managedIdentityToken.Token;
}
I set the bearer token in the Header for the request going to the api. But i always get a redirect or i get a message tsating that i should allow cookies.
Most of the authetication stuff is based upon the sample 5-1-Roles
I would like to secure acces to the api but i don’t know how.
Tried several things, but keep getting the same eroor. I read a lot about auth, buit it’s complicated. Probably i forgot something, but i dopn’t know what. And cannot seem to find the right search terms