从Identity Server4刷新令牌和访问令牌

时间:2019-06-25 06:26:04

标签: asp.net-core identityserver4 refresh-token

我尝试使用以下方法获取访问令牌和刷新令牌,但它返回invalid_scope和错误的请求。如果删除范围的offline_scope值,它将仅返回访问令牌。

 var tokenResponse = await protocolClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest
                    {
                        Address = disco.TokenEndpoint,
                        ClientId = ServiceIdentity,
                        ClientSecret = ServiceKey,
                        Scope = "offline_access",
                        GrantType = "GrantTypes.ClientCredentials"
                    });
                    return tokenResponse.AccessToken;

1 个答案:

答案 0 :(得分:1)

那是设计使然。 GrantTypes.ClientCredentials不支持刷新令牌。原因是您可以使用相同的客户端ID和密码随时获取新的访问令牌。

相关问题