liveBook · Manning

API key

As explained in Secure APIs

An API key is a credential string that identifies or authorizes a client when it accesses an API.

An API key is a credential used to authenticate API requests, typically for nonhuman identities such as applications, services, and devices. Unlike generally short-lived access tokens, API keys may remain valid for weeks or months, so they need expiration and rotation. section 7.1

Treat an API key like a valuable access credential. Hardcoding one into an IoT device can let anyone who obtains the device steal the key and gain unfettered API access. Design for expiration, allow users to rotate keys, and avoid embedding reusable credentials where attackers can extract them. section 1.6 section 7.1

Figure 7.1 During authentication, users exchange their credentials for an access token. During authorization, the API checks whether the access token is valid and the user has access to the requested resources.
figure

Use the authentication-versus-authorization flow to distinguish proving an identity with a credential from checking access to requested resources. section 7.1

How Secure APIs covers it

How deep it goes
Defines API keys, contrasts them with access tokens, and addresses expiration, rotation, and hardcoded-key risks.
Examples
Uses hardcoded keys in connected devices as the concrete failure example, including devices that expose APIs.
What you can do after
Operate API credentials by setting expiration, supporting rotation, and recognizing the danger of hardcoded keys.
How it connects
Connects API keys with authentication, authorization, access tokens, nonhuman identities, and IoT security.

Also explained in

Compare how 13 books explain API key →

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.