"收到无效的承载令牌"使用新请求的持票人令牌时

时间:2017-11-08 08:06:31

标签: c# oauth-2.0 asp.net-web-api2 identityserver3

我使用Postman,首先我要求代币:

  

https://my-internal-test-site/identity/connect/token

这为我提供了正确的令牌响应:

{
    "access_token": "MY_BEARER_TOKEN",
    "expires_in": ?,
    "token_type": "Bearer",
    "refresh_token": "MY_REFRESH_TOKEN"
}

比我发布到我需要的实际网址:

  

https://my-internal-test-site/api/start-stuff

将此值用于Authorization标头:

BEARER *MY_BEARER_TOKEN*

虽然这是一个新请求的令牌,但我得到了:

{
    "message": "Authorization has been denied for this request."
}

当我查看我的API日志时,我看到了:

Error | IdentityServer3.AccessTokenValidation.IntrospectionEndpointTokenProvider | Error returned from introspection endpoint: An error occurred while sending the request.

Warn | Microsoft.Owin.Security.OAuth.OAuthBearerAuthenticationMiddleware | invalid bearer token received

这很奇怪,因为它是我正在使用的新标记。也许出现其他问题导致这种情况,但如果是这样的话,这里没有描述,也没有在Identity Server日志中描述。这看起来很好:

Info | IdentityServer3.Core.ResponseHandling.TokenResponseGenerator | Creating token response
Info | IdentityServer3.Core.ResponseHandling.TokenResponseGenerator | Processing token request
Info | Identity.Api.Monitoring.IdentityEventService | Information - 2020 - Refresh token issued -  - IdentityServer3.Core.Events.RefreshTokenDetails
Info | Identity.Api.Monitoring.IdentityEventService | Information - 2000 - Access token issued -  - IdentityServer3.Core.Events.AccessTokenIssuedDetails
Info | Identity.Api.Monitoring.IdentityEventService | Success - 3000 - Endpoint success -  - IdentityServer3.Core.Events.EndpointDetail
Info | IdentityServer3.Core.Endpoints.TokenEndpointController | End token request
Info | IdentityServer3.Core.Results.TokenResult | Returning token response.
  

知道会发生什么事吗?

1 个答案:

答案 0 :(得分:0)

数字,我得到的错误不是发生的错误:

  

潜在的api url无法公开访问

这就是为什么它在本地工作但不在测试服务器上,因为那时我使用的是公共网址。奇怪的是,这些都没有出现在任何日志中,但你能做些什么......

  

我检查了系统管理员并修复了它。

相关问题