What's inside a JWT
A JSON Web Token has three parts separated by dots: a header saying how it's signed, a payload of claims such as the user ID and expiry time, and a signature. The header and payload are just Base64URL-encoded JSON, so anyone holding the token can read them.
Decoding is useful when debugging sign-in problems: you can check which user a token belongs to, which permissions it carries and whether it has expired.
- exp: when the token expires. Expired tokens are rejected by servers.
- iat: when the token was issued.
- sub: the subject, usually the user ID.