Asp.net core Identity Server 4-身份模型授予类型
我正在尝试从中实现标识模型,我正在尝试让NetCoreConsoleClient在我的localhost:5000上使用我的IdentityServer4,在我的localhost:5001上使用我的Api 我的出发点是混合和Api流 因此,我在IdentityServer4代码中添加了以下客户端:Asp.net core Identity Server 4-身份模型授予类型,asp.net-core,identityserver4,Asp.net Core,Identityserver4,我正在尝试从中实现标识模型,我正在尝试让NetCoreConsoleClient在我的localhost:5000上使用我的IdentityServer4,在我的localhost:5001上使用我的Api 我的出发点是混合和Api流 因此,我在IdentityServer4代码中添加了以下客户端: // Hybrid grant client new Client { ClientId = "hclient",
// Hybrid grant client
new Client
{
ClientId = "hclient",
AllowedGrantTypes = GrantTypes.Hybrid,
ClientSecrets =
{
new Secret("secret".Sha256())
},
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api1"
},
}
在NetCoreConsoleClient中,我更改了以下代码行:
static string _authority = "http://localhost:5000";
static string _api = "http://localhost:5001";
private static async Task SignIn()
{
// create a redirect URI using an available port on the loopback address.
string redirectUri = string.Format("http://127.0.0.1:7890/");
var options = new OidcClientOptions
{
Authority = _authority,
ClientId = "hclient",
RedirectUri = redirectUri,
Scope = "OpenId Profile api1",
FilterClaims = false,
Browser = new SystemBrowser(port: 7890)
};
我在一篇博文中读到评论,我应该使用混合流授权类型
web浏览器将打开,但我始终会看到:
抱歉,出现错误:未经授权的\u客户端
我做错了什么?检查日志……日志会有帮助,但我可以看到您没有向OIDClientOptions对象提供客户端机密。您得到任何结果吗?