我正在使用IdentityServer4创建一个认证服务器。
我正在创建一个客户端,这个客户端将使用资源所有者密码凭证进行访问。
但是我想知道client_id和client_secret应该是什么。
client_id应该是一个人类可读的客户端名称,例如应用程序名称,还是应该是一个随机数或字符串?
client_secret是一个字符串,但它的值应该是什么?UUID、随机字符串、base64字符串?
我查看了IdentityServer4和OpenId的文档,但没有找到任何指导。
下面是他们在文档中提供的例子。
new Client
{
ClientId = "client",
// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},
// scopes that client has access to
AllowedScopes = { "api1" }
}
正如你在例子中看到的,他们设置了一个人类友好的client_id。
Github: 6779ef20e75817b79602
Google: 292085223830.apps.googleusercontent.com
Instagram: f2a1ed52710d4533bde25be6da03b6e3
Windows Live: 00000000400ECB04
阅读更多关于 IdentityServer4 的秘密 此处