I trying to consume a .NET Core Minimal Api endpoint, which is secured with Bearer tokens, via the .http
client in Visual Studio.
I'm setting a valid Authorization: Bearer <token>
in the request given below in my .http
file,
@HostAddress = http://localhost:5085
@BearerToken = <token>
GET {{HostAddress}}/api/v1/categories
Accept: application/json
Authorization: Bearer {{BearerToken}}
but the response is always 401 Unauthorized
.
I trying to consume a .NET Core Minimal Api endpoint, which is secured with Bearer tokens, via the .http
client in Visual Studio.
I'm setting a valid Authorization: Bearer <token>
in the request given below in my .http
file,
@HostAddress = http://localhost:5085
@BearerToken = <token>
GET {{HostAddress}}/api/v1/categories
Accept: application/json
Authorization: Bearer {{BearerToken}}
but the response is always 401 Unauthorized
.
1 Answer
Reset to default 0Since the endpoint host, @HostAddress = http://localhost:5085
is http
and not https
, it is likely that in the Program.cs
file, you have configured, app.UseHttpsRedirection()
which expects an https
endpoint.
So, instead of http://localhost:5085 you must use the equivalent https
endpoint for @MyAuth.Auth_HostAddress