A developer inspects API request headers sent from a connected smartphone on a monitor while testing authentication between the app and a server.
Publié le 3 décembre 2026

OAuth 2.0 with the client credentials grant is generally a suitable choice for server-to-server business integrations requiring scoped access, automated token renewal and independent partner management. API keys remain appropriate for simpler, controlled connections, while mutual TLS and cryptographic request signatures provide additional protection for sensitive operations.

Selecting an API authentication method requires more than comparing credentials. Backend developers must establish whether the calling application can protect a secret, whether access is delegated by a user, and how permissions can be withdrawn without interrupting unrelated services. A credential suitable for an internal reporting application may be inappropriate for an external payment integration or a distributed mobile client.

The operational lifecycle matters as much as the initial authentication mechanism. Token validation, credential storage, partner offboarding, secret rotation and account recovery determine whether security controls remain effective in production. A reliable architecture restricts what each integration can access while providing predictable procedures for renewing credentials, responding to compromises and maintaining service availability.

Choosing the right API authentication strategy

  • Use OAuth 2.0 client credentials for machine-to-machine integrations requiring granular permissions and automated access-token renewal.
  • Treat credentials embedded in distributed mobile applications as potentially public rather than confidential authentication secrets.
  • Consider mutual TLS or signed requests when sensitive business operations require stronger assurance of the calling service’s identity.
  • Design token validation, revocation and credential rotation together to contain security incidents without unnecessarily interrupting legitimate integrations.

Why Is Embedding an API Key in a Mobile App Unsafe?

Embedding an API key in a mobile application is unsafe when the key grants access to protected resources because distributed application packages cannot reliably keep credentials confidential. Someone who obtains the application can potentially recover its embedded secrets and use them outside the intended client. A shared mobile API key therefore cannot establish a trustworthy user or service identity.

During an authorized security assessment, developers can examine compiled APK or IPA packages, inspect binary strings and analyse application behaviour. Network proxy tools can also reveal credentials transmitted by applications when traffic inspection is permitted by the test environment and its TLS configuration. Code obfuscation can increase extraction difficulty but cannot guarantee confidentiality.

An API key can serve two different purposes: identifying a consuming application for usage tracking or authenticating a caller through possession of a secret. A publicly distributed key may support the first purpose, but it cannot reliably fulfil the second when anyone can retrieve it.

A client-side API key is potentially acceptable when all of the following conditions apply:

  • The API exposes only information intended for public consumption.
  • Rate limits and consumption quotas are enforced on the server.
  • The key cannot authorize sensitive transactions or access confidential records.
  • Exposure of the key does not create unacceptable financial or operational risks.

Otherwise, a backend proxy should retain the confidential credentials and authenticate incoming users or applications before forwarding authorized requests. The proxy must enforce permissions rather than simply relay arbitrary traffic.

Distributed secrets also complicate incident response. Revoking a shared embedded key can disable every installed application version that depends on it, particularly when users cannot immediately upgrade.

Separating public application identifiers from confidential credentials reduces this dependency and creates a foundation for delegated authorization through OAuth 2.0.

How to Configure OAuth 2.0 for a Third-Party Business Integration?

Configure OAuth 2.0 by selecting a grant appropriate to the integration architecture, registering the third-party client and restricting its permissions to the required business operations. Use authorization code with PKCE when an integration acts on behalf of a user, and client credentials when a confidential backend service accesses resources under its own authorization.

The authorization code grant with Proof Key for Code Exchange (PKCE) binds the authorization exchange to the initiating client instance. For machine-to-machine communication, the client credentials grant allows a confidential service to obtain access tokens without requiring interactive user authorization.

The implicit grant should not be selected for new integrations because of its token exposure and replay risks. The IETF best practices for OAuth 2.0 security recommend protective measures for redirect-based flows, restricted token privileges and stronger client authentication.

Configuring scopes, redirect URIs and client credentials is a hands-on step of any OAuth 2.0 business integration.



In multi-tenant B2B environments, authorization must remain associated with the correct organization. Maintain separate authorization records and, where applicable, refresh tokens for each tenant. When a commercial relationship ends, revoke the corresponding grants and refresh tokens, and address any outstanding access tokens according to the supported revocation architecture.

OAuth provides delegated authorization rather than a general-purpose user authentication protocol. A valid bearer access token establishes that the request presents an accepted authorization credential, not necessarily that its current holder is the original recipient. OpenID Connect can support user authentication, while asymmetric client authentication and sender-constrained tokens can strengthen service identity assurance.

OAuth 2.0 integration deployment checklist

  1. Select the appropriate grant and record the client type, authorization flow and trust boundaries in an approved architecture diagram.
  2. Register the integration client and produce a permission matrix documenting the minimum required scopes for each business operation.
  3. Configure exact redirect URI matching, PKCE and session-bound state where applicable, and retain test results demonstrating rejection of invalid callbacks.
  4. Store confidential client credentials exclusively in controlled backend environments and document their secret-manager references and access policies.
  5. Test tenant isolation, token expiration and partner offboarding, producing a validation report confirming that unauthorized access is rejected.

Once client registration and permission boundaries are established, the remaining architectural decision is whether token-based access provides enough operational benefit to justify its additional infrastructure compared with API keys.

API Keys vs OAuth Tokens: Which Fits Server-to-Server Communication?

OAuth access tokens are generally preferable for server-to-server communication involving multiple business partners, differentiated permissions or frequent credential renewal. API keys can remain suitable for narrowly scoped integrations between trusted services when secure storage, independent revocation and controlled rotation are available. The decision depends on access requirements, credential lifecycle management and the consequences of compromise.

Both mechanisms can authorize service requests, but they manage access differently. The following comparison assumes a conventional long-lived API key and an OAuth access token issued through the client credentials grant.

API key and OAuth access token comparison for server-to-server integrations
Decision criterion API keys OAuth 2.0 access tokens
Number of integration partners Suitable for limited, directly managed relationships Supports centralized authorization across multiple registered clients
Permission granularity Depends on custom key-level authorization policies Supports scope-based access restrictions
Credential lifetime Often long-lived unless expiration is configured Can be issued with a short, defined lifetime
Revocation Depends on key registry and cache management Depends on token type, validation architecture and revocation support
Renewal and rotation May require coordinated replacement across systems Access-token renewal can be automated; client credentials still require lifecycle management
Infrastructure complexity Relatively straightforward credential validation Requires token issuance and authorization infrastructure

A stolen API key exposes the resources permitted by that key until expiration, revocation or effective replacement. A stolen short-lived OAuth bearer token provides access within its assigned permissions and remaining validity period. Short token lifetimes therefore reduce the exposure window, provided the underlying client credential has not also been compromised.

For higher-risk integrations, mutual TLS (mTLS) or HMAC-based request signatures can complement authorization controls. Request signatures require appropriate freshness and replay protections, while mTLS can authenticate services through certificates.

RFC 9700 recommends asymmetric OAuth client authentication methods such as mTLS and private_key_jwt. These approaches remove the requirement for a shared symmetric client authentication secret, although private keys and certificates still require protection and renewal. Certificate-bound access tokens can additionally restrict token use to an authorized certificate holder.

Automated token acquisition reduces the need for partners to coordinate routine access-token replacements. That advantage becomes particularly relevant when integrations operate continuously across independently managed production environments.

Regardless of the issuance mechanism, protected endpoints must verify presented credentials correctly. This becomes particularly important when OAuth access tokens use the JWT format.

JWT Validation Mistakes That Can Expose Protected API Endpoints

JSON Web Tokens (JWTs) can expose protected API endpoints when applications mistake readable token contents for verified credentials. A resource server must validate the cryptographic signature, permitted signing algorithm, trusted issuer, intended audience and applicable time restrictions before using token claims to make access decisions.

The IETF JSON Web Token security best practices document historical vulnerabilities involving signature verification and algorithm confusion, alongside recommendations for preventing token substitution and inappropriate trust in received claims.

Common JWT validation mistakes and their security consequences
Validation mistake Potential consequence Required control
Accepting the none algorithm for signed access tokens Unsigned credentials may be treated as authentic Require signatures and explicitly permitted algorithms
Confusing RS256 and HS256 Incorrect key and algorithm handling may undermine signature verification Bind verification keys to their intended algorithms
Ignoring the issuer (iss) Tokens from an unintended authorization server may be accepted Validate against a configured trusted issuer
Ignoring the audience (aud) A token intended for another service may grant access Require the expected resource-server audience
Ignoring expiration (exp) Expired access tokens may remain usable Enforce expiration under the configured token policy

Many JWT libraries distinguish decoding from cryptographic verification. Decoding reads the token header and payload; it does not establish their authenticity. An authorized integration test should submit an invalidly signed test token to a protected endpoint and confirm that the request is rejected before business logic executes.

Signature verification also does not replace authorization. A correctly signed token may contain a role that was valid when issued but has since been withdrawn. Sensitive operations may therefore require a current server-side permission check in addition to token validation.

Locally validated JWTs can remain acceptable until expiration unless the resource server implements additional invalidation controls. Short token lifetimes limit this period, while a revocation list using a validated token identifier such as jti can support targeted invalidation. Centralized token introspection or permission checks offer alternatives where immediate access withdrawal is essential, at the cost of additional infrastructure dependencies.

Reliable token validation limits unauthorized access, but production security also depends on protecting and replacing the credentials used to authenticate clients and sign tokens.

When Should API Secrets Be Rotated in Production Systems?

Rotate production API secrets when their confidentiality becomes uncertain, their authorized ownership changes or their configured lifetime expires. Immediate revocation is appropriate for potentially compromised credentials, while planned rotation can use a controlled transition period. The rotation policy should reflect credential privileges, exposure risks, operational dependencies and the ability of consuming systems to adopt replacements.

Security events that warrant reviewing and potentially replacing API credentials include:

  • A developer or contractor leaving an organization after having access to shared secrets.
  • Credentials appearing in source repositories, diagnostic logs or unintended storage locations.
  • A business partner changing its integration infrastructure or terminating its agreement.
  • A security incident affecting a credential store, deployment pipeline or authorized consumer.

Event-driven rotation complements rather than automatically replaces scheduled expiration and renewal. The OWASP Secrets Management Cheat Sheet recommends automated lifecycle management, regular rotation where appropriate and revocation of unnecessary or potentially compromised secrets.

For planned rotations, a dual-credential transition can preserve service availability when the authentication infrastructure supports simultaneous credentials. Issue the replacement, distribute it securely to authorized consumers, confirm successful adoption and then revoke the previous credential.

Rotating production secrets requires monitoring authentication failures closely so legitimate integrations survive the switchover.



Third-party applications may cache credentials in running processes or deployment configurations. Integration agreements should therefore define notification channels, replacement procedures and maximum transition periods for planned rotations. Suspected compromise requires a separate emergency procedure that prioritizes containment over a routine overlap window.

During the switchover, monitor HTTP 401 responses against established service baselines, identify consumers still using the previous credential through non-secret credential identifiers, and verify successful authentication with the replacement. Never record raw credential values in monitoring systems.

Define a revocation acceptance criterion before deployment. For example, a planned rotation may require confirmation that all critical consumers have migrated and that previous-credential usage has ceased throughout an observation period covering their normal execution schedules.

Credential lifecycle controls are most effective when every storage location is accounted for, including mobile devices holding user access tokens and refresh tokens.

Why Is Storing Login Tokens in Plain Text Dangerous for Mobile Apps?

Storing login tokens in plain text is dangerous because a person who obtains a valid bearer session credential may impersonate its legitimate holder without knowing the account password. Unprotected tokens can become accessible through compromised devices, insecure application storage, diagnostic output or backups, potentially allowing authenticated sessions to continue outside the intended mobile application.

Different exposure surfaces require different protections. Encrypting a local database does not prevent an application from independently writing credentials into diagnostic logs or exporting them through an insecure backup configuration.

Mobile token exposure surfaces and corresponding protections
Exposure surface Risk Recommended protection
Unprotected local files or preferences Credential extraction when storage isolation is bypassed or misconfigured Platform-protected credential storage
Device and cloud backups Tokens copied into unintended or insufficiently protected environments Appropriate backup exclusions and credential accessibility policies
Crash reports and diagnostic logs Credentials transmitted to monitoring systems Token redaction before diagnostic collection
Debugging interfaces and runtime inspection Tokens exposed while processed by the application Restricted production debugging and minimized credential retention

On iOS, Keychain provides platform-managed storage for sensitive credentials. On Android, Android Keystore can protect cryptographic keys used to encrypt locally stored tokens. EncryptedSharedPreferences is an example found in existing Android implementations; teams maintaining such applications should evaluate its suitability and migration requirements rather than automatically selecting it for new development.

Cross-platform storage abstractions require particular attention. A generic key-value storage interface is not necessarily equivalent to native secure storage. Verify the underlying implementation on each supported operating system, including backup behaviour and credential accessibility settings.

A refresh token may represent a greater exposure than a short-lived access token because it can potentially obtain replacement access tokens. Use differentiated lifetimes, refresh-token rotation or sender constraints where supported, and server-side revocation appropriate to the session architecture.

Protecting existing sessions reduces credential theft risks, while phishing-resistant authentication addresses a different problem: preventing fraudulent acquisition of authenticated access in the first place.

SMS Codes vs Security Keys: Which Offers Stronger Phishing Protection?

FIDO-compatible security keys provide stronger phishing protection than SMS verification codes because their authentication responses are cryptographically bound to the legitimate service identity. SMS codes rely on manually transferred verification values that can be intercepted or relayed to the intended service. Security keys reduce this weakness without relying on the confidentiality of a transmitted code.

SMS authentication is vulnerable to scenarios involving fraudulent SIM transfers and real-time phishing. A fraudulent website can solicit a verification code and relay it to the legitimate authentication service while the code remains valid. The fact that a code is single-use does not make it phishing-resistant.

FIDO authentication through WebAuthn uses public-key cryptography and relying-party identity binding. A correctly implemented authentication ceremony prevents a fraudulent domain from obtaining an assertion valid for a different relying party. Manually entered SMS and time-based one-time password (TOTP) codes do not provide equivalent origin binding.

The NIST digital authentication and phishing-resistance requirements distinguish phishing resistance from replay resistance. Although the publication primarily addresses US government information systems, its technical distinctions are relevant to private-sector authentication architecture.

Authentication factor selection for business integration users
Decision criterion SMS verification codes FIDO security keys
Phishing resistance No cryptographic binding to the legitimate service Phishing-resistant when correctly implemented
Deployment requirements Phone number registration and message delivery Authenticator provisioning and compatible clients
User interaction Receive and manually enter a code Complete an authenticator-supported verification ceremony
Account recovery Requires secure handling of phone number changes Requires replacement, backup authenticator or controlled recovery procedures
Business suitability Lower-risk or transitional deployments where policy permits Privileged access and sensitive business workflows

Passkeys can offer an intermediate deployment option by bringing phishing-resistant authentication to compatible devices without requiring a separate physical key for every user. However, synchronized passkeys and non-exportable hardware credentials should not be treated as equivalent for every assurance requirement.

Evaluate the complete account recovery path. Strong primary authentication can be undermined if an attacker can replace the registered authenticator through a weaker recovery channel.

These controls protect the human identities administering business integrations. Machine credentials and the sensitive information exchanged through those integrations require complementary cryptographic protections.

Key takeaways

  • Document which identities can retrieve sensitive information before selecting the encryption boundary and assigning decryption permissions.
  • Separate credential replacement from encryption-key retirement: historical encrypted data may still depend on keys that are no longer used for new operations.
  • Include partner dependencies, recovery procedures and cryptographic service availability in the integration threat model.

How to Encrypt Sensitive Business Data Without Disrupting Daily Operations?

Encrypt sensitive business data without disrupting daily operations by matching encryption boundaries to the actual threat model, identifying confidential fields and testing how protected data interacts with existing applications. Combine transport encryption, appropriate storage encryption and selective application-level protection, supported by centralized key management and a migration process that preserves authorized business workflows.

Encryption in transit protects information exchanged between applications and API endpoints. Encryption at rest protects stored information against relevant storage-level exposure scenarios. Application-level encryption can establish an additional confidentiality boundary by restricting which services can decrypt selected information, including when the underlying storage system is accessible.

These mechanisms are complementary rather than interchangeable. Database storage encryption can preserve normal application query behaviour, but it does not necessarily protect information from an authorized database session. Field-level or column-level encryption provides more targeted protection, although conventional search, sorting and indexing may become restricted for encrypted values.

Begin by identifying confidential fields, their authorized consumers and the operations that depend on them. Use a key management service (KMS) to control cryptographic key access and lifecycle management. Where searching is necessary, evaluate whether permitted metadata or carefully designed search mechanisms can fulfil the requirement without exposing unacceptable information.

Migration testing should cover more than successful encryption and decryption. Evaluate representative query workloads, reporting processes, application integrations, backup restoration and disaster recovery. Confirm that authorized services can obtain the required keys and that historical data remains recoverable throughout planned key transitions.

Hypothetical scenario: encrypting confidential supplier records

A purchasing platform needs to protect supplier banking details while preserving searches based on approved supplier identifiers. Selective encryption protects the banking fields, while authorized, non-sensitive identifiers remain available for routine searches.

During migration, the platform tests payment workflows, reporting queries and backup restoration before retiring previous storage arrangements. This approach illustrates how encryption boundaries can be aligned with business requirements rather than applied indiscriminately.

OWASP secret management guidance also highlights the operational implications of encryption-key rotation, including potential data re-encryption. API credentials and encryption keys should share a consistent governance framework for ownership, auditing, access control and incident response, without necessarily sharing identical storage mechanisms, access policies or expiration schedules.

Start by inventorying production API endpoints, their authorized consumers, associated credentials and sensitive data flows. Select an authentication method for each trust boundary, document credential and encryption-key lifecycle requirements, and test access withdrawal and service recovery before deploying changes to business-critical integrations.

Frequently asked questions about API authentication and business integration security
Does every business API need an API gateway?

No. An API gateway can centralize credential validation, rate limiting, routing and security monitoring, particularly when several services expose external endpoints. A smaller integration may implement these controls directly within its application infrastructure. Regardless of architecture, resource-specific authorization and tenant isolation must be enforced at the appropriate trust boundary.

Does HTTPS replace API authentication?

No. Conventional HTTPS protects data in transit and allows clients to verify the server’s identity through certificate validation. It does not automatically authenticate the calling application or establish its permission to access a business resource. API credentials, OAuth tokens or mutual TLS address additional identity and authorization requirements.

What is the difference between an opaque access token and a JWT access token?

An opaque access token does not expose authorization claims in a format directly readable by its consumer and typically requires lookup or introspection to determine its validity. A JWT access token can carry verifiable claims that a resource server may validate locally. The choice affects authorization-server dependencies, revocation behaviour and the complexity of endpoint validation.

When should an API return HTTP 401 instead of HTTP 403?

HTTP 401 generally indicates that valid authentication credentials are missing or that the presented credentials are unacceptable. HTTP 403 indicates that the server refuses the requested operation, such as when an authenticated caller lacks the required permissions. Distinguishing these responses helps legitimate integration partners identify authentication failures without treating every authorization problem as an expired credential.

Should each business partner have separate API credentials?

Yes, independently managed partner credentials are generally preferable to a shared credential distributed across organizations. They support individual access restrictions, attribution, incident containment and partner offboarding. Separate production and non-production credentials also help prevent testing environments from obtaining unintended access to live business resources.

Rédigé par Daniel Morgan, A documentary analyst focused on business applications, API integrations and interconnected operational systems. Compares software documentation, integration patterns and workflow requirements to explain data consistency, automation and platform selection. Enables business readers to assess technical trade-offs and recognise potential integration risks.