Anyone have a luck in providing aud
token different from the domain name of the api endpoint? My Blazor calls the asp.net app (api) and got the error:
It worked totally fine when I had api app Application id and Jwt's "aud" in a form of api://[GUID]/write.access
After I updated it to the domain name (need custom claims, which won't work without it) it stopped working throwing the error.
Where I updated the audience in Entra:
I guess that should be enough. The only possible root cause that I have in mind is different domain names: api endpoint is https://someappname.azurewebsites.net/accounts, and from you can see on the screenshots attached it's different
You can set the expected aud claim value in JwtBearer like this:
.AddJwtBearer(opt =>
{
opt.Authority = _configuration["openid:authority"];
opt.Audience = "paymentapi";
...
this should be what the API should expect to see in the received access token.
I did write a blog post about this here: Troubleshooting JwtBearer authentication problems in ASP.NET Core