admin 管理员组

文章数量: 1086019

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.

Share Improve this question asked Mar 27 at 10:55 Rizan ZakyRizan Zaky 4,6925 gold badges29 silver badges41 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Since 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

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)