Authentication is one of the first questions in almost every enterprise integration: how does System A prove to System B that it is allowed to call the API?
The answer may involve an API key, OAuth 2.0, a certificate, a signed token or several mechanisms together.
Authentication versus authorisation
Authentication asks: Who are you?
Authorisation asks: What are you allowed to do?
A client may authenticate correctly but still receive 403 Forbidden because it lacks permission for the requested resource.
API keys
An API key is a shared secret issued to a consumer.
X-API-Key: abc123...
API keys are easy to implement, but they should still be protected like passwords. Use them over HTTPS, rotate them where possible and avoid exposing them in source code or logs.
Basic Authentication
Basic Auth sends a username and password in the Authorization header.
Authorization: Basic <base64(username:password)>
Base64 is encoding, not encryption, so HTTPS is essential.
Basic Auth can be acceptable in controlled scenarios, although modern enterprise APIs often prefer token-based approaches.
Bearer tokens
Many APIs expect:
Authorization: Bearer <token>
The important question is how the token was obtained. A bearer token may come from OAuth or another identity service.
Anyone who possesses a valid bearer token can normally use it until it expires or is revoked, so it must be protected.
OAuth 2.0 client credentials
The client-credentials flow is one of the most common approaches for system-to-system APIs.
Integration
|
| client_id + client_secret
v
Authorization Server
|
| access_token
v
Integration
|
| Bearer access_token
v
API
The integration stores the client credentials securely, requests a short-lived token and then calls the API using that token.
This separates long-lived application identity from short-lived API access.
OAuth scopes
Scopes define what a client is allowed to do.
Examples:
contracts.read
contracts.write
documents.read
Apply least privilege. A read-only integration should not automatically receive broad administrative permissions.
JWT
A JSON Web Token is a common token format containing a header, payload and signature.
The payload may include issuer, subject, audience, expiry, roles and scopes.
A signed JWT can be validated to confirm it has not been altered. However, a JWT is not automatically encrypted, so do not place sensitive data into it merely because it looks encoded.
Mutual TLS
Normal HTTPS authenticates the server to the client. Mutual TLS also authenticates the client using a certificate.
mTLS is common in high-security enterprise environments and may be used alongside OAuth.
Operational considerations include certificate issuance, private-key protection, expiry and rotation.
HMAC signatures
HMAC is commonly used for webhook authentication and request signing.
The sender calculates a signature using the request body and a shared secret. The receiver independently calculates the expected signature and compares the result.
This helps confirm both authenticity and integrity.
SAML is usually not your API authentication method
SAML is mainly associated with browser-based enterprise SSO. An application may use SAML for human login while using OAuth for APIs.
That distinction matters when designing enterprise systems.
Store credentials securely
Credentials belong in secure credential stores, secrets managers or environment secrets.
Avoid storing them in Git repositories, screenshots, documentation, plain-text exports or logs.
Understanding 401 and 403
401 Unauthorized usually means authentication failed: missing token, expired token or invalid credentials.
403 Forbidden often means authentication succeeded but the caller lacks permission.
This distinction is useful when troubleshooting integrations.
Choosing a mechanism
| Requirement | Common approach |
|---|---|
| Simple internal API | API key or Basic Auth where appropriate |
| Server-to-server enterprise API | OAuth 2.0 client credentials |
| Signed claims | JWT |
| High-assurance client identity | mTLS |
| Webhook verification | HMAC signature |
| Human enterprise SSO | SAML or OpenID Connect |
The correct choice should follow the provider's supported model and organisational security standards.
Final thoughts
API authentication is not just about making a 401 disappear.
A good design considers identity, permission, token lifetime, rotation, certificate expiry, auditability and least privilege.
When those concerns are handled properly, authentication becomes a dependable part of the integration architecture rather than a recurring production problem.