Explain the difference between Basic Auth, API Keys, and JWT/OAuth2, and when is each appropriate?
Last updated
Basic Auth sends base64-encoded
user:passon every request with no scoping or expiry. It requires HTTPS and suits internal tools or prototypes.API Keys are opaque tokens that identify the calling app, not a user. They are good for server-to-server access and rate limiting, but weak on fine-grained authorization and easy to leak.
OAuth2 is a delegation framework that issues scoped, expiring access tokens, often as JWTs (signed, self-contained claims). Use it for user login, mobile/SPA, or third-party access without sharing passwords.