admin管理员组文章数量:1394520
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
本文标签:
版权声明:本文标题:asp.net core - Visual Studio .http file returns 401 even though Authorization header is set for the request - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744094909a2590107.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论