【发布时间】:2017-06-30 19:20:57
【问题描述】:
我正在尝试将我的刷新令牌生命周期设置为 2 周。我试过通过.. FromSeconds、FromMinutes、FromHours,但它总是将刷新令牌设置为与访问令牌相同的生命周期。我将不胜感激任何帮助。这是我目前在 configureServices 中的内容:
services.AddOpenIddict(options =>
{
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<AppDbContext>();
// Register the ASP.NET Core MVC binder used by OpenIddict.
// Note: if you don't call this method, you won't be able to
// bind OpenIdConnectRequest or OpenIdConnectResponse parameters.
options.AddMvcBinders();
// Enable the token endpoint.
options.EnableTokenEndpoint("/connect/token");
// Enable the password flow.
options.AllowPasswordFlow()
.AllowRefreshTokenFlow()
.SetAccessTokenLifetime(TimeSpan.FromMinutes(1))
.SetRefreshTokenLifetime(TimeSpan.FromMinutes(20160));
// During development, you can disable the HTTPS requirement.
options.DisableHttpsRequirement();
});
【问题讨论】:
-
but it always sets the refresh token to the same lifetime as the access token-> 你是怎么得出这个结论的? -
这是我得到的 400 的正文:{"error":"invalid_grant","error_description":"刷新令牌不再有效。"}。它设置为 14 天,但一旦访问令牌不再有效,无论我设置多远,刷新令牌也是如此。
-
值得注意的是,刷新令牌是一次性令牌(除非您禁用滑动到期)。您确定这不是导致您看到的错误的原因吗?