Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
An access token is something like a temporary pass issued after login. The IETF's RFC 6749 (OAuth 2.0) defines it as a credential for reaching protected resources, a string that represents the permission granted to an app.
How does an access token work?
Think of a hotel room key. You finish identity checks and procedures at check-in, and are handed a key that opens only your room. The key stops working once your stay is over. An access token is that room key.
RFC 6749 divides the parties into four: the owner of the resource, the app that acts for the owner (the client), the authorization server that issues the token, and the server that holds the resource. In most cases the authorization server confirms the owner and obtains permission, then hands the app a token. The app attaches that token when it asks the resource server.
The RFC explains that a token represents the range and period the owner has approved. The content of the string normally has no meaning to the app. It can be an identifier, or it can carry information together with a signature. Failures in authentication on the API side are gathered in API authentication flaws. For help with how your tokens are handled, contact us.
Why does an access token matter?
RFC 6750 says that anyone who holds a bearer token can reach the matching resource. It has the same nature as a room key that lets in whoever holds it. So it must be protected from leaking, both when stored and when carried.
A leaked token can be used by people other than the owner. Narrowing the valid range and period reduces the effect of a leak. A token resembles an API key, but most are issued based on a user's permission, and some are issued under the app's own credentials. The basics of handling are these.
- Send over an encrypted channel (TLS).
- Limit where tokens are kept on the device or in the browser to what is needed.
- Keep the valid period and usable range to the minimum.
- Have a procedure to revoke at once when a leak is suspected.
Related terms
- JWT: a document that makes proof of login portable
- API key: a long passphrase that shows a caller is allowed to use a service
- OAuth: a mechanism for giving another app permission without handing over the password
- Session: the series of usage from login to the end
Frequently asked questions
Are an access token and a JWT the same thing?
No. RFC 6749 says a token can be an identifier or can carry information with a signature, and that forms vary. A JWT is one format for the content of a token. An access token is not necessarily a JWT.
What happens if an access token is stolen?
RFC 6750 says anyone who holds a bearer token can use the matching resource. A stolen token may be used until it expires. Keep the valid period short and decide a revocation procedure.
Next step
Failures in API authentication are in API authentication flaws. The free URL check shows only what is visible from outside, and for a review of token handling, contact us.
Frequently asked questions
Are an access token and a JWT the same thing?
No. RFC 6749 says a token can be an identifier or can carry information with a signature, and that forms vary. A JWT is one format for the content of a token. An access token is not necessarily a JWT.
What happens if an access token is stolen?
RFC 6750 says anyone who holds a bearer token can use the matching resource. A stolen token may be used until it expires. Keep the valid period short and decide a revocation procedure.