Powered by AppSignal & Oban Pro

Long-lived JWT for testing

long_lived_jwt_token_for_testing.livemd

Long-lived JWT for testing

Section

{:ok, user} = Sanbase.Accounts.User.find_or_insert_by(:username, "no_subscription_long_lived_jwt")
# 5 years
ttl = {5 * 52, :weeks}

# NOTE:
# Execute this on stage as the encoding and signing will use the stage signing keys
# Doing this locally will use some default local key which won't work on stage
{:ok, %{access_token: token}} =
  SanbaseWeb.Guardian.get_jwt_tokens(user, %{access_token_ttl: ttl, refresh_token_ttl: ttl})
{:ok, user, claims} = SanbaseWeb.Guardian.resource_from_token(token)

IO.puts("User from token is #{user.username}")