I created an asp.net core API which uses openIdConnect library to authenticate users using Azure AD and it works fine when I test it from the browser but when I try to test the API from post man by generating an access token and use it to access the API, the response is a redirect to login page indicating that I am unauthorized, so how can I access the API from postman:
I solved this problem by adding Jwt bearer authentication to ConfigureServices
in my startup.cs
and decorates the controller with [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme + "," + OpenIdConnectDefaults.AuthenticationScheme)]
so if I am trying to access the api from the browser it will use the openIdConnect scheme, else it will use the jwt scheme