Token has expired
at ServiceStack.Auth.JwtAuthProviderReader.AssertJwtPayloadIsValid(JsonObject jwtPayload)
at ServiceStack.Auth.JwtAuthProviderReader.CreateSessionFromPayload(IRequest req, JsonObject jwtPayload)
at ServiceStack.Auth.JwtAuthProviderReader.PreAuthenticate(IRequest req, IResponse res)
at ServiceStack.EnumerableExtensions.Each[T](IEnumerable`1 values, Action`1 action)
at ServiceStack.AuthenticateAttribute.Execute(IRequest req, IResponse res, Object requestDto)
at ServiceStack.ServiceStackHost.ApplyRequestFiltersSingle(IRequest req, IResponse res, Object requestDto)
at ServiceStack.ServiceStackHost.ApplyRequestFilters(IRequest req, IResponse res, Object requestDto)
at ServiceStack.Host.Handlers.GenericHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName)
这种情况频繁发生。
Plugins.Add(new AuthFeature(() => new AuthUserSession(),
new IAuthProvider[]
{
new CredentialsAuthProvider(),
new JwtAuthProvider(AppSettings)
{
AuthKeyBase64 = Configuration.GetValue("AuthKeyBase64"),
RequireSecureConnection = false,
PersistSession = false
}
}
));
它应该是这样的,或者我只是错误地使用它?!
答案 0 :(得分:1)
异常表示JWT令牌已过期,当发生这种情况时,客户端需要重新进行身份验证才能获得新的令牌或use its refresh token。
JWT docs contains a lot of detail on JWT expiration包括用于控制JWT有效期的配置:
new JwtAuthProvider {
ExpireTokensIn = TimeSpan.FromDays(14), // JWT Token Expiry
ExpireRefreshTokensIn = TimeSpan.FromDays(365), // Refresh Token Expiry
}