JWT Structure Explained
A JWT consists of three Base64URL-encoded parts:
1. Header
``json
{
"alg": "HS256",
"typ": "JWT"
}
`
Specifies the signing algorithm and token type.2. Payload
`json
{
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022,
"exp": 1516242622
}
``
Contains the claims (statements about the user and metadata).3. Signature
Created by signing the header and payload with a secret key.Common JWT Claims
| Claim | Name | Description |
|---|---|---|
| iss | Issuer | Who issued the token |
| sub | Subject | Who the token represents |
| aud | Audience | Intended recipient |
| exp | Expiration | When the token expires |
| iat | Issued At | When the token was created |
| nbf | Not Before | Token not valid before this time |