Roman
Roman

Reputation: 643

Token has expired

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)

this exeptions happens frequently.

Plugins.Add(new AuthFeature(() => new AuthUserSession(),
   new IAuthProvider[]
     {
       new CredentialsAuthProvider(),
       new JwtAuthProvider(AppSettings)
         {
           AuthKeyBase64 = Configuration.GetValue("AuthKeyBase64"),
           RequireSecureConnection = false,
           PersistSession = false
         }
     }
));

Is that the way it should be or I just use it wrong way?!

Upvotes: 1

Views: 446

Answers (1)

mythz
mythz

Reputation: 143369

The Exception indicates the JWT token has expired, when that happens the client needs to re-authenticate to get a new one or use its refresh token.

The JWT docs contains a lot of detail on JWT expiration including the config to control how long JWTs are valid for:

new JwtAuthProvider {
    ExpireTokensIn        = TimeSpan.FromDays(14),  // JWT Token Expiry
    ExpireRefreshTokensIn = TimeSpan.FromDays(365), // Refresh Token Expiry
}

Upvotes: 1

Related Questions