Increase token expiry time in guardian jwt

In the Guardian jwt the exp is default set for every newly generate token:

inside claims like this

 "aud" => "ChromaticUser:181",
 "exp" => 1533199493,
 "iat" => 1533197693,
 "iss" => "Haitracker",
 "jti" => "2e52621c-110a-412d-86e3-f9cb00c145e4",
 "pem" => %{},
 "sub" => "ChromaticUser:181",
"typ" => "access"


Is there any way we can change it(increase it)?. I couldn’t find anything inside documentation

I want to send the token to the user in the email for password reset. And I want to increase its expiry.


Should work with ttl option, like ttl: {4, :weeks}. Would be the last parameter to sign_in.

UPD s. example in docs here

1 Like

I think you have to override default ttl :

# with plug
MyApp.Guardian.Plug.sign_in(conn, resource, %{some: "claim"}, ttl: {1, :minute})

# Or directly by encode_and_sign
MyApp.Guardian.encode_and_sign(resource, %{}, ttl: {1, :minute})

Or you can do this globally:

config :your_app, YourApp.Guardian,
  # ...
  ttl: {1, :minute}
  # ...