我已经设置了一个在IIS中运行的IdentityServer3实例。IdentityServer3 PostMan invalid_client
var validators = new List<Registration<ISecretValidator>>
{
new Registration<ISecretValidator, HashedSharedSecretValidator>(),
new Registration<ISecretValidator, X509CertificateThumbprintSecretValidator>()
};
// .Register() is an extension method that setups that setups the
// IdentityServerServiceFactory
var factory = new EntityFrameworkServiceOptions()
.Register()
.UseInMemoryUsers(Users.Get());
factory.SecretValidators = validators;
app.Map($"/{IdentityServer.Path}", server =>
{
server.UseIdentityServer(new IdentityServerOptions()
{
RequireSsl = false,
SiteName = siteName,
SigningCertificate = Certificate.Load(),
Factory = factory,
// Currently does nothing. There are no plugins.
PluginConfiguration = ConfigurePlugins,
AuthenticationOptions = new AuthenticationOptions()
{
EnablePostSignOutAutoRedirect = true,
// Currently does nothing. There are no IdentityProviders setup
IdentityProviders = ConfigureIdentityProviders
}
});
});
我已经在客户端凭证流程的EF数据库中设置了一个客户端。因此,在Client
表中有一个客户端,我已向客户端访问ClientScopes
表中的范围,并且我已在ClientSecrets
表中为客户端提供了一个秘密。
存储在数据库中的相关值(未列出的所有值都是IdentityServer3默认):
ClientId = 'client'
Flow = 'ClientCredentials [3]'
ClientScope = 'api'
ClientSecret = 'secret'.Sha256()
IdentityServer正在测试服务器上运行,这就是为什么我没有选择“本地请求访问令牌”的原因。
当我点击“请求令牌”我收到以下错误记录:
2016-09-16 16:18:28.470 -05:00 [Debug] Start client validation
2016-09-16 16:18:28.470 -05:00 [Debug] Start parsing Basic Authentication secret
2016-09-16 16:18:28.470 -05:00 [Debug] Parser found secret: "BasicAuthenticationSecretParser"
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Secret id found: "client"
2016-09-16 16:18:28.470 -05:00 [Debug] No matching hashed secret found.
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Secret validators could not validate secret
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Client validation failed.
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] End token request
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Returning error: invalid_client
我真的不知道为什么验证无法验证的秘密。它被保存在数据库中,Sha256和IdentityServer可以解析和验证Sha256。
UPDATE: 我得到它的工作做从邮递员POST,并填写相应的X WWW的形式,进行了urlencoded领域,但我还没有想出如何得到它的使用授权工作标签和Postman的“获取新访问令牌”功能。不能用于从IdentityServer3获取令牌吗?
我将回调URL添加到客户端的重定向uris。我将我的令牌名称更新为“承载者”。我将Auth网址更改为授权终点。 (我的授权类型仍然是Client Credentials)。我在本地检查了请求访问令牌复选框,并且仍然使用此方法得到“invalid_client”...客户端是否必须使用“授权码”流设置? –
我已经使用客户端证书和资源代码来完成它的工作。唯一的区别是资源代码邮差会弹出一个登录对话框。这对于我工作的开发很方便,因为大量REST服务调用需要与特定用户关联。 – GlennSills