如何在 APB 7 中更改 OpenIddict AccessToken 寿命?

huangapple go评论46阅读模式
英文:

how can i change the OpenIddict AccessToken Lifetime in apb 7?

问题

如何更改访问令牌的默认到期时间?

英文:

enter image description here
How to change the default expiration time of accesstoken?

答案1

得分: 1

你可以在你的模块中使用这段代码:

context.Services.AddAuthentication(options =>
{
    // ...
})
.AddAbpOpenIdConnect("oidc", options =>
{
    // ...

    options.Events.OnTicketReceived = validatedContext =>
    {
        validatedContext.Properties.IsPersistent = true;
        validatedContext.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddDays(365);
        return Task.CompletedTask;
    };
});
英文:

You can use this code in your module

 context.Services.AddAuthentication(options =>
                {
                    ...
                })
                .AddAbpOpenIdConnect("oidc", options =>
                {
                    ...
                   
                    options.Events.OnTicketReceived = validatedContext =>
                    {
                        validatedContext.Properties.IsPersistent = true;
                        validatedContext.Properties.ExpiresUtc = DateTimeOffset.UtcNow.AddDays(365);
                        return Task.CompletedTask;
                    };
                });

huangapple
  • 本文由 发表于 2023年2月10日 16:39:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75408673.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定