【问题标题】:Refresh token exception in identity server 4身份服务器 4 中的刷新令牌异常
【发布时间】:2020-08-21 18:22:41
【问题描述】:

基于以下内容,我正在刷新Refresh token renewal

但是令牌过期后,请求新的刷新令牌时出现错误

下面是我的代码

   var tokenClientOptions = new TokenClientOptions
                        {
                            Address = "https://localhost:5000", //configuration.TokenEndpoint,
                            ClientId = "webclient",//openIdConnectOptions.ClientId,
                            ClientSecret ="secret"  // openIdConnectOptions.ClientSecret
                        };

                        var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
                        using var httpClient = httpClientFactory.CreateClient();

                        var tokenClient = new TokenClient(httpClient, tokenClientOptions);
                        var tokenResponse = await tokenClient.RequestRefreshTokenAsync(refreshToken, cancellationToken: cancellationToken).ConfigureAwait(false);

以下是我的 Html 响应。

我已经给出了基本路径身份服务器 4。请让我知道出现错误的原因..提前致谢。

【问题讨论】:

  • 异常包含Raw属性中的HTML页面,该页面可能包含有关错误的更多信息。
  • @MartinStaufcik 我更新了问题.. Html respose 添加
  • 试试https://localhost:5000/connect/token 换成Address
  • 非常感谢它的工作..

标签: asp.net-core identityserver4


【解决方案1】:

以编程方式请求令牌的Token Endpoint of Identity Server/connect/token

地址的URL必须是https://localhost:5000/connect/token

【讨论】:

  • Thaanks ..如果令牌过期,如何重定向 tl 登录?下面 if (tokenResponse.IsError) { context.RejectPrincipal();返回; }
  • 刷新令牌允许在没有用户交互的情况下请求新的访问令牌。您可能需要将客户端的 AllowOfflineAccess 设置为 true,如文档中所述:identityserver4.readthedocs.io/en/latest/topics/…
  • 其实我已经给了AbsoluteRefreshTokenLifetime÷10分钟和滑动5分钟..在10分钟内我会刷新令牌,.如果我在10分钟后访问它不会刷新令牌对吗?如果我错了,请纠正我?在这种情况下,我需要重定向到登录页面...有可能吗?
  • 是的,我相信这是正确的。对于重定向,它适用于授权请求,如下所述:identityserver4.readthedocs.io/en/latest/topics/signin.html,因此在这种情况下您需要使用authorize 请求而不是token
猜你喜欢
  • 2015-10-01
  • 2020-01-09
  • 2020-01-16
  • 2018-05-27
  • 1970-01-01
  • 1970-01-01
  • 2018-05-15
  • 2019-09-28
  • 1970-01-01
相关资源
最近更新 更多