Pcornel
Automation · APIs

OAuth 2.0

Cheat sheet · https://pcornel.dk/topic.php?topic=5315

Back to the Topic

Answer

Delegated authorization framework for obtaining and using access tokens through defined grant flows and client roles.

Remember

  • OAuth 2.0 ≠ authentication by itself; OpenID Connect adds standardized identity semantics on top.
  • Access token ≠ refresh token; they have different audience, lifetime and handling requirements.
  • Authorization Code flow ≠ Client Credentials flow; user delegation and machine identity solve different problems.
  • Token issued ≠ API access guaranteed; audience, scope and resource policy still control authorization.

First checks

  • curl -sS -X POST <token-url> -d grant_type=client_credentials -d client_id=<id> -d client_secret=<secret> -d scope=<scope> — client credentials flow
  • Token caching until expiry — efficiency
  • Scopes granted to client — least privilege

Verify in this order

client → token endpoint → access token → API

Where it usually breaks

OAuth token issuance proves the authorization server accepted a grant; it does not prove identity semantics or resource-server authorization.

OAuth 2.0 API boundary map

BoundaryHealthy evidenceSuspicious evidence
Caller / requestEnvironment/version, identity and exact request contract are attributableHidden defaults, wrong endpoint/version, leaked or mismatched credentials
Server / responseStatus, headers, structured body and request ID are interpreted togetherStatus-only handling, ignored error body, ambiguous async result or unsafe retry
State / proofWrite result is reconciled with resource read-back or acceptance testResponse success treated as final target success without verification
TroubleshootingFirst failed boundary is preserved, changed minimally and retestedBlind retries, credential rotation, replay or payload edits before evidence is captured

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5315

Confirmation

Confirm action

Continue?