About bearer token generator
A bearer token is a secret string that grants access to whoever presents it, usually sent as Authorization: Bearer <token>. This tool creates random tokens suitable for that.
Making good tokens
- Use enough randomness: 32 bytes (256 bits) is a common choice.
- Base64URL is safe in URLs and headers; hex is easy to read.
- Never base a token on a user name, date or counter.
Operating them
- Store only a hash of the token on the server where possible.
- Set expiry and allow revocation.
- Send tokens only over HTTPS.
A worked example
A 32-byte token in Base64URL is 43 characters long, and in hex it is 64 characters. You would send it as Authorization: Bearer <token>. Both forms have the same strength, 256 bits of randomness.
Storage
- Store a hash of the token, not the token itself, so a leaked database does not leak working tokens.
- Show the full token only once, when it is created.
- Let users revoke and replace tokens.
