I am getting an unauthorized error when loading images in my app. This is happening because image url is missing the token in authorization header. I want authorize the image url when token is present as a query parameter.
I found this quection is similar, but I am currently not able to use the answer since current application is using AzureAD
to authorize the api's.
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration, "AzureAD");
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllers().RequireAuthorization();
endpoints.EnableDependencyInjection();
endpoints.Select().Filter().OrderBy()
.Count().Expand().MaxTop(100).Count();
});
As in the answer I installed the Invio.Extensions.Authentication.JwtBearer
and called AddQueryStringAuthentication()
.
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(options =>
{
Configuration.Bind("AzureAD", options);
options.AddQueryStringAuthentication();
},
options => { Configuration.Bind("AzureAD", options); });
Then I send the JWT token as a query parameter. But I still get the unauthorized error.