本文介绍了错误:invalid_scope-IdentityServer Flow.ClientCredential的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的IdentityServer3中有一个客户端

I'm having a Client in my IdentityServer3

new Client
{
    ClientName = "Client Credentials Flow Client",
    Enabled = true,
    ClientId = "clientcredentials.reference",
    Flow = Flows.ClientCredentials,

    ClientSecrets = new List<Secret>
    {
        new Secret("secret".Sha256()),
    },

    AllowedScopes = new List<string>()
    {
        "read",
        "write"
    }
}

我在本地IIS中托管了令牌服务,并尝试使用邮递员ping令牌,但是给出了错误{"error":"invalid_scope"}

I hosted the Token Service in my local IIS and I tried to ping the Token using Postman, but it given an error {"error":"invalid_scope"}

Host URL: 
    https://localhost:5775/core/connect/token
Header: 
    Content-Type:application/x-www-form-urlencoded
Body:
    grant_type=client_credentials
    &cliend_id=clientcredentials.reference
    &client_secret=secret

推荐答案

检查范围声明中的范围读取"和写入"

Check the Scopes "read" and "write" in Scopes declaration

new Scope
{
    Name = "read",
    DisplayName = "Read data",
    Type = ScopeType.Resource,
    Emphasize = false,

    ScopeSecrets = new List<Secret>
    {
        new Secret("secret".Sha256())
    }
},
new Scope
{
    Name = "write",
    DisplayName = "Write data",
    Type = ScopeType.Resource,
    Emphasize = true,

    ScopeSecrets = new List<Secret>
    {
        new Secret("secret".Sha256())
    }
}

我认为它错过了...检查一次...

I think its missed... Check it once...

这篇关于错误:invalid_scope-IdentityServer Flow.ClientCredential的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 02:58