Identity Server 4-设置访问令牌生存期

时间:2018-05-03 08:18:15

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

我正在将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,那么它会正确设置访问令牌的生命周期。

这种行为有什么理由吗?

1 个答案:

答案 0 :(得分:1)

您没有测试实际值,因为它是0.您应该使用TotalSeconds。

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