【问题标题】:Identity Server 4- Setting the Access Token lifetime身份服务器 4- 设置访问令牌生命周期
【发布时间】:2018-05-03 08:18:15
【问题描述】:

我将 Identity Server 4 与我的 ASP.NET Core MVC 应用程序一起使用。它工作正常。然后我尝试使用以下代码设置访问令牌和身份令牌生命周期。

//AccessTokenLifetime = new TimeSpan(2,0,0).Seconds,  /*This is not working*/
AccessTokenLifetime = 7200,  /* This is setting the life time correctly */

当我检查数据库中的“[Clients]”表时,AccessTokenLifeTime 设置为 0(如果使用 TimeSpan(2,0,0))。但是如果我直接分配整数 7200 那么它会正确设置访问令牌的生命周期。

这种行为有什么原因吗?

【问题讨论】:

    标签: asp.net-identity asp.net-core-2.0 identityserver4


    【解决方案1】:

    您没有测试实际值,因为那是 0。您应该改用 TotalSeconds。

    AccessTokenLifetime = new TimeSpan(2,0,0).TotalSeconds
    

    【讨论】:

    • 是的,那是我的错误。我没有正确意识到差异。感谢您指出。
    猜你喜欢
    • 2019-01-03
    • 2018-10-26
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 2017-07-10
    • 2012-06-05
    • 2020-11-03
    • 2020-02-26
    相关资源
    最近更新 更多