在标头中使用正确的访问令牌的API调用给了我401未授权

问题描述 投票:0回答:1

我正在请求针对我们在之前项目中使用的身份服务器应用程序的令牌,用于当前项目。在我的本地机器上,所以localhost级别。

令牌请求有效:

IdentityServer3.Core.ResponseHandling.TokenResponseGeneratorCreating token response
IdentityServer3.Core.ResponseHandling.TokenResponseGeneratorProcessing token request
Identity.Api.Monitoring.IdentityEventServiceInformation - 2020 - Refresh token issued -  - IdentityServer3.Core.Events.RefreshTokenDetails
Identity.Api.Monitoring.IdentityEventServiceInformation - 2000 - Access token issued -  - IdentityServer3.Core.Events.AccessTokenIssuedDetails
Identity.Api.Monitoring.IdentityEventServiceSuccess - 3000 - Endpoint success -  - IdentityServer3.Core.Events.EndpointDetail
IdentityServer3.Core.Endpoints.TokenEndpointControllerEnd token request
IdentityServer3.Core.Results.TokenResultReturning token response.

我收到了这个回复:

{
    "access_token": "myaccesstoken",
    "expires_in": 86400,
    "token_type": "Bearer",
    "refresh_token": "myrefreshtoken"
}

现在,如果我在我的请求中使用该令牌,我会得到一个401 unauthorized响应:

enter image description here

从表面上来看,我希望这个调用可以正常工作,因为我传递了一个正确的令牌。那么,我该怎么做才能弄清楚它为什么不起作用?

c# .net oauth-2.0 identityserver3
1个回答
1
投票

授权标头应该有Bearer而不是BASIC

Authorization: Bearer SomeTokenHere
© www.soinside.com 2019 - 2024. All rights reserved.