Oauth 带有验证密钥令牌请求的授权代码导致客户端响应无效

Oauth 带有验证密钥令牌请求的授权代码导致客户端响应无效,oauth,openid,identityserver3,appauth,Oauth,Openid,Identityserver3,Appauth,我目前正在评估AppAuth(),以便与当前使用IdentityServer 3的STS一起在本机移动应用程序中使用。我已将客户端配置为如下所示: newidentityserver3.Core.Models.Client { 启用=真, ClientId=“app”, ClientName=“app”, ClientUri=“app:/”, Flow=Flows.AuthorizationCodeWithProof键, RequireSent=false, RequireSignOutProm

我目前正在评估AppAuth(),以便与当前使用IdentityServer 3的STS一起在本机移动应用程序中使用。我已将客户端配置为如下所示:

newidentityserver3.Core.Models.Client
{
启用=真,
ClientId=“app”,
ClientName=“app”,
ClientUri=“app:/”,
Flow=Flows.AuthorizationCodeWithProof键,
RequireSent=false,
RequireSignOutPrompt=false,
SlidingRefreshTokenLifetime=28800,
AllowAccessTokensViaBrowser=true,
重定向URI=新列表
{
“应用程序:/sign”
},
PostLogoutRedirectUris=新列表
{
“应用程序:/signout”
},
AllowedScopes=新列表
{
StandardScopes.OpenId.Name.Name,
StandardScopes.Email.Name.Name,
StandardScopes.Profile.Name.Name,
StandardScopes.Roles.Name.Name,
StandardScopes.OfflineAccess.Name,
}
}
初始授权请求成功,IdentityServer3返回授权代码。现在我尝试了一个后续的令牌请求,这导致HTTP 400出现无效的_客户端错误,IdentityServer 3日志中出现以下消息:

2018-04-17 10:16:38.324 +02:00 [Information] Start token request
2018-04-17 10:16:38.324 +02:00 [Debug] Start client validation
2018-04-17 10:16:38.324 +02:00 [Debug] Start parsing Basic Authentication secret
2018-04-17 10:16:38.324 +02:00 [Debug] Start parsing for secret in post body
2018-04-17 10:16:38.324 +02:00 [Debug] No secret in post body found
2018-04-17 10:16:38.324 +02:00 [Debug] Start parsing for X.509 certificate
2018-04-17 10:16:38.324 +02:00 [Debug] X.509 certificate not found.
2018-04-17 10:16:38.324 +02:00 [Information] Parser found no secret
2018-04-17 10:16:38.324 +02:00 [Information] No client secret found
2018-04-17 10:16:38.324 +02:00 [Information] End token request
2018-04-17 10:16:38.324 +02:00 [Information] Returning error: invalid_client

我是否理解有什么错误,或者IdentityServer3为什么不返回访问令牌?

您需要在
授权代码
流的令牌请求中对
客户端进行身份验证。因此,您需要为您的客户设置
ClientSecrets

new IdentityServer3.Core.Models.Client
{
    /// your properties

    ClientSecrets = new List<Secret>
    {
        new Secret("secret".Sha256())
    }
}
newidentityserver3.Core.Models.Client
{
///你的财产
ClientSecrets=新列表
{
新密码(“Secret.Sha256())
}
}
您需要在令牌请求中以查询字符串的形式发送
client\u secret


或者您可以使用
基本身份验证
。在这种情况下,您需要在身份验证标头中添加
Base64(ClientId:ClientSecret)

您是否在授权请求中设置了
code\u质询
,在令牌请求中设置了
code\u验证器
?是的。我在返回授权代码的授权请求中设置了
code\u challenge
。我还在令牌请求中设置了
code\u验证器
,这导致了如上所述的无效客户端响应。在IdSrv3中将客户端密码添加到客户端的配置中,并在令牌请求中另外设置授权标头后,我获得了一个id和访问令牌。是的,但奇怪的是,您应该需要此流的客户端密码。请看:这似乎是一个IdentityServer3问题,我刚刚尝试了这个,它似乎起作用了。我不明白的是为什么需要客户的秘密?PKCE用于公共客户端,其中客户端机密无论如何都没有意义。