error:invalid_scope - IdentityServer Flow.ClientCredential

一个人想着一个人 提交于 2019-12-12 03:49:49

问题


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"
    }
}

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

Note: I'm using pure IdentityServer3 package not Thinktecture


回答1:


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...



来源:https://stackoverflow.com/questions/42767613/errorinvalid-scope-identityserver-flow-clientcredential

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!