Skip to content

Instantly share code, notes, and snippets.

@cthornton
Last active August 29, 2015 14:03
Show Gist options
  • Save cthornton/b4be57ea19cf4eb60737 to your computer and use it in GitHub Desktop.
Save cthornton/b4be57ea19cf4eb60737 to your computer and use it in GitHub Desktop.
JWT Creation with jti
auth_header = JWT.encode({
user_id: 123,
jti: rand(2 << 64).to_s, # One-time use token
iat: Time.now.to_i, # Specify the time the token was issued.
exp: Time.now.to_i + 2 # Expire the token in 2 seconds
}, "<my shared secret>")
RestClient.get("http://api.example.com/", authorization: auth_header)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment