不记名令牌意外过期

bearer tokens expires unexpectedly

我编写了一个使用 OAuth 承载身份验证的 Web api。问题是当我在本地工作时它按预期工作但在主机(远程)上令牌在它的到期时间跨度 365 天之前到期。它持续不到一个小时。下面是我的代码。

Startup.cs:

public void ConfigureOAuth(IAppBuilder app)
        {
            OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                TokenEndpointPath = new PathString("/Auth/Login"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(365),
                AllowInsecureHttp = true,
                Provider = new AuthorizationServerProvider(),
                
            }; 
            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()
            {
                Provider = new OAuthBearerProvider()
            });
        }

我问这个之前已经搜索了很多次了。抱歉,如果这个问题已经得到解答。

我找到了解决办法。刚刚将机器密钥添加到我的网络配置中。密钥可以从 IIS 机器密钥函数生成。