API Authentication

API authentication is how an API verifies which app or user is making a request, using methods such as API keys, OAuth 2.0 access tokens or certificates, so only authorized callers can use it.

AdvancedCategory: Website, application and API security

Also called: API auth, API authorization, bearer token, OAuth for APIs, JWT

What is API authentication?

Every request to an API should answer the question "who is this?" before the API does anything. API authentication provides that answer, and authorization then decides what the caller may do. OWASP ranks broken authentication as the second biggest API risk, covering problems like weak tokens, missing checks and credentials sent insecurely.

Common methods

  • [API keys](/glossary/api-key/): a long secret string identifying the calling application. Simple, but usually not tied to a specific user and easily leaked.
  • [OAuth 2.0](/glossary/oauth/) access tokens: short-lived tokens issued by an authorization server, with "scopes" that limit what they can do. The standard for user-delegated access, such as letting an app read your calendar.
  • JSON Web Tokens (JWTs): a common token format that carries signed claims about the caller. They must be properly validated: signature, issuer, audience and expiry.
  • Mutual TLS: both client and server present certificates, common for server-to-server and financial APIs.

Best practices

  • Use OAuth 2.0 tokens with narrow scopes and short lifetimes for user access.
  • Always send credentials over HTTPS, never in URLs.
  • Validate every token fully on every request.
  • Apply rate limiting and lockouts to authentication endpoints.
  • Rotate keys and secrets, and revoke them immediately when people leave or keys leak.
  • Don't build your own authentication scheme; use well-tested libraries and identity providers.

Related terms

Sources

  1. RFC 6749: The OAuth 2.0 Authorization Framework (IETF)
  2. API2:2023 Broken Authentication (OWASP Foundation)

Drafted with AI assistance, then edited and fact-checked by a person. How we use AI.