gpt4 book ai didi

c# - 我们可以将访问 token 设置为不过期吗?

转载 作者:太空狗 更新时间:2023-10-30 01:30:01 24 4
gpt4 key购买 nike

我们正在使用 Identity Server4,默认的访问 token 过期时间是 3600 秒。可以设置成永不过期吗?

public static IEnumerable<Client> GetClients()
{
return new List<Client>
{
new Client
{
ClientId = "client",

// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,

// secret for authentication
ClientSecrets =
{
new Secret("secret".Sha256())
},

// scopes that client has access to
AllowedScopes = { "api1" },
AccessTokenLifetime=3600
}
};

最佳答案

从技术上讲,AccessTokenLifetime 被声明为一个 int,因此您可以这样做

AccessTokenLifetime = Int32.MaxValue;

但这真的不是一个好主意。一旦创建了访问 token ,它就会继续工作,我不认为你在支持中使它过期会像你想的那样工作。

为了好玩

TimeSpan t = TimeSpan.FromSeconds(Int32.MaxValue);
Console.WriteLine(t.Days);

导致非常丑陋的 24855 天或 68 年。

关于c# - 我们可以将访问 token 设置为不过期吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48145819/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com