Use an access token in a Bearer header.
A bearer token lets its holder request the access that the token permits. The application programming interface (API) still validates the token and checks the requested operation.
Why this lesson?
A reporting app needs to read a report. It uses an access token instead of sending the user’s password to the API.
Learning goal and prerequisites
Send a bearer token
The reporting app sends an access token that it obtained earlier. It does not send the user’s password to the Reports API. The API checks the token and the permission needed to read the report.
Inspect request, response, and claims
Try a failure scenario
↳ Change a condition
Read the detailed explanation
Why it exists, how it works, and where it fits
A protected application programming interface (API) should not need the user’s main password every time a client calls it. Bearer access tokens solve that problem by giving the client a separate credential that represents approved access. The API can accept that token without learning the user’s password.
The word bearer describes the security property: possession is enough. If a client has a valid bearer token, it can present the token in the Authorization header and request the access that token allows. The API must still validate the token’s issuer, audience, time limits, and permissions before trusting it.
Bearer tokens are useful because they can be narrower and shorter-lived than a primary sign-in credential. One token might be valid only for the Orders API and only for reading orders. That limits how much authority a client needs to carry.
The tradeoff is theft. If an attacker copies a bearer token, the attacker may be able to replay it until it expires or is revoked. Hypertext Transfer Protocol Secure (HTTPS), careful storage, and log hygiene are therefore essential. Later lessons add sender constraints so a copied token is not enough by itself.
Investigation
Inspect the traffic, select a diagnosis in the checkpoint, then reveal the repair.
Check your understanding
Pass the lesson quiz
Answer every question correctly to unlock the next lesson. Retry as often as you need.