【问题标题】:Refresh Token and Access Token from Identity Server4从 Identity Server4 刷新令牌和访问令牌
【发布时间】:2019-06-25 06:26:04
【问题描述】:

我尝试使用以下方法获取访问和刷新令牌,但它返回 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;

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 那我该怎么办?
    • 我也发送了 GrantTypes.ResourceOwnerPasswordAndClientCredentials。但还是不行
    • 只需删除offline_access。需要时通过客户端凭据获取新的访问令牌。对于ResourceOwnerPassword offline_access 必须工作,但是......在大多数情况下它仍然是过度的,因为你在本地拥有重复初始请求的所有凭据
    • 我获得了访问令牌,但我还需要刷新令牌
    • 再说一遍:你说我需要,但答案是:你不需要。为什么你猜你需要刷新客户信用?你能解释一下你的观点吗?
    猜你喜欢
    • 2020-01-09
    • 2021-08-23
    • 2015-04-01
    • 2014-09-18
    • 2020-11-09
    • 2018-08-01
    • 2020-04-14
    • 2021-07-16
    • 2020-10-15
    相关资源
    最近更新 更多