Which authentication and authorization mechanisms can be used for API requests?
Answer
Common mechanisms include HTTP Basic over TLS, Bearer tokens such as opaque tokens or JWTs, API keys, OAuth 2.0 access tokens, session cookies, HMAC/request signing and mutual TLS. OpenID Connect commonly supplies identity/login on top of OAuth 2.0, while the access token authorizes API calls. Authentication establishes who the caller is; authorization determines which resources/actions that identity may access. Tests should cover expired or revoked credentials, wrong scope/audience and valid identities without the required permission.
Strong answer includes
- Basic, Bearer/JWT, API key and OAuth
- session/signature/mTLS alternatives
- authentication versus authorization
Practical example
A valid JWT lets a normal user read their own profile but an attempt to call the admin endpoint returns 403. That confirms authentication succeeded and the failure is an authorization boundary, not an invalid token.