liveBook · Manning

Bearer authentication

As explained in Secure APIs

A bearer token is an access credential whose possession is sufficient to present it for authorization without proving possession of a separate key.

Bearer authentication uses a token that can be presented for authorization without proving possession of a separate key. In an API request, place the token after the Bearer keyword in the Authorization header: Authorization: Bearer <token>. section 8.1

OpenAPI describes this mechanism as an HTTP security scheme. A JWT bearer definition identifies the scheme as Bearer and records JWT as its format; the scheme can protect the whole API or selected operations. section 8.1

JWT bearer scheme

components: securitySchemes: JWTBearer: description: Bearer JSON Web Token type: http scheme: Bearer bearerFormat: JWT section 8.1

Figure 8.1 We define the security schemes that protect our API in the specification’s components section under securitySchemes, and we apply them globally to the API under the specification’s security field or per operation using the operation’s security field.
figure

Use the figure to compare global authentication settings with per-operation overrides, such as leaving one endpoint public while protecting another. section 8.1

How Secure APIs covers it

How deep it goes
Defines the scheme fields and global or per-operation application, but does not explain token issuance or validation internals.
Examples
Uses an OpenAPI JWTBearer YAML definition and protected or public endpoint configuration.
What you can do after
Configure bearer-token authentication and its scope in an OpenAPI specification.
How it connects
Connects HTTP authentication, Authorization headers, JWTs, OpenAPI, and operation-level security.

Also explained in

Compare how 5 books explain bearer authentication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secure APIs. The section links point to the parts of the book it draws on.