Bookmarks

Access token

A string that proves the client’s rights to a protected resource: which actions it is allowed to perform and for how long; the client presents it to the server with every request.

Also: authorisation token

checked 9 Nov

All terms

An access token is issued after successful authorisation — most often through OAuth 2.0 — and is short-lived, often under an hour. The client sends it in the Authorization header, and the server checks it and processes the request. This way the application works with an API on the user’s behalf without ever learning their password.

How it works

StepWhat happens
Authorisationthe client goes through the authorisation server, for example via the authorization code flow
Issuethe authorisation server returns an access token and usually a refresh token
Requestthe client sends a request to the API with a header like Authorization: Bearer <token>
Validationthe resource server checks the token and what it allows, and decides whether to process the request
Renewalwhen the token expires, the client obtains a new one using the refresh token, without asking the user

Token formats

There is no single format: OAuth 2.0 describes the token as a string that either denotes an identifier the server can look the rights up by, or carries them inside in a verifiable form; to the client the string is usually opaque. In the first case it is a random string, and the resource server asks the authorisation server what stands behind it. In the second it is usually a JWT: the data is embedded in the token and signed, and the resource server verifies the signature locally, without extra requests.

The most common type is the bearer token: whoever presents the string gets access, with no proof of key possession. That is why tokens are sent only over HTTPS, issued for a short time and with a limited scope.

How to handle tokens

  • send the token only over HTTPS: an intercepted token gives an attacker the same access
  • issue short-lived tokens — RFC 6750 recommends an hour or less
  • limit the scope: a token for reading a calendar must not allow sending email
  • do not store it in cookies that are transmitted in the clear

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • JWTJSON Web Token

    A JWT is a token format: signed data inside. An access token is a role: it is used to prove rights with a request, and it may be a JWT or a random string.

  • SSOSingle sign-on

    SSO is an approach where a single sign-in grants access to several systems; the access token is one of the tools that make this work.

  • MFAmulti-factor authentication

    MFA requires several proofs of identity at sign-in; an access token comes into play after sign-in and does not replace authentication.

In depth in the references

where the topic is covered in detail