Software

API Security: OAuth 2.0, Tokens, Rate Limiting and Authorisation

APIs can expose company data and critical business functions directly. Security must therefore be part of the architecture, not an afterthought.

What’s in this article?

APIs can expose company data and critical business functions directly. Security must therefore be part of the architecture, not an afterthought.

Authentication alone is not enough. Verifying who a user is does not mean they have the right to access every resource.

TLS Must Be Compulsory

Use TLS for production API traffic so credentials and tokens are not transmitted in clear text.

OAuth 2.0

OAuth 2.0 provides a standard framework for different client types and authorisation scenarios. Select the flow for the use case.

Access-token lifetime

Compromise of a long-lived access token increases risk. Where needed, use short-lived access tokens and controlled refresh tokens.

Authorisation

Control endpoint access by role or permission. Also enforce object-level authorisation: changing an ID must not give access to another customer’s data.

Using scopes

Granting tokens access only to necessary resources and operations supports least privilege.

Request rate limiting

Limits by user, client or IP can constrain abuse, brute-force attempts and faulty client loops.

Secret management

Do not store API keys or client secrets in Git repositories. Environment variables or secret vaults can be used.

Input Validation

Treat all API input as untrusted data. Validate its schema, type, length and business rules.

Audit log

  • Who performed the operation?
  • Which resource was accessed?
  • What operation was performed?
  • When was it performed?
  • Was the transaction successful?

Production integration checklist

In production, mandatory TLS, OAuth 2.0 and access-token lifetimes belong to the operating model, not just development. Define the source and destination systems, data owner, authentication method, mapping table and person responsible for failures for each integration. A working endpoint is not a successful integration if it updates the wrong product, customer or order.

Treat timeouts, rate limits, temporary network outages, duplicate requests and unexpected responses as normal production scenarios. Retry only temporary failures, and use idempotency where repeating an operation could have financial or operational side effects. Moving long-running work to a queue decouples the user request from external service performance; failed jobs can then be reprocessed in a controlled way.

Monitor business outcomes as well as HTTP status codes. An API may return HTTP 200 even though no orders reach the ERP. Show request count, error rate, P95 latency, retry count, queue backlog and last successful synchronisation alongside business metrics such as orders, stock or customer records transferred. Correlation IDs and structured logging help trace one operation across services during an incident.

  • Authentication and secret management
  • Data mapping and schema validation
  • Timeout and retry policy
  • Idempotency and duplicate detection
  • Request rate-limit management
  • Structured logs and correlation IDs
  • Business data reconciliation
  • Alert and dashboard

API Contract, Failure Mode, and Data Consistency

Do not design only the successful request-response path. Define a clear API contract covering mandatory TLS, OAuth 2.0 and access-token lifetimes, including required fields, data types, enum values, authentication, timeouts, error codes and handling of breaking changes. Decide in advance which responses trigger retries, which stop processing and which require human intervention to make integration behaviour more predictable.

Failure-mode design must cover not only total external service outages but also slow responses, partial data, duplicate or out-of-order events, rate limits and temporary authentication failures. Retries can use exponential backoff and, where appropriate, jitter. Idempotency or unique business keys reduce duplicate-record risk when orders, payments, inventory or customer operations are processed again.

A successful API response alone does not establish data consistency. Periodically reconcile source and destination systems by record count, total amount, last synchronisation time or business ID to detect discrepancies. Structured logs, correlation IDs and central error tracking can identify the failing service faster. These checks turn a working connection into an auditable, sustainable operational component.

  • Request and response schema validation
  • Timeout and retry matrix
  • Idempotency or unique business keys
  • Request rate limits and capacity management
  • Correlation IDs and structured logging
  • Source-to-destination reconciliation checks
  • Breaking-change and versioning policy

B10 Digital Agency’s integration approach

B10 Digital Agency treats integration as system architecture, not just an API connection: data contracts, security, retries, queues, observability, reconciliation and operational processes are designed together.

Frequently Asked Questions

Is OAuth 2.0 the authentication protocol?

OAuth is primarily an authorisation framework. Authentication can use it alongside layers such as OpenID Connect.

Is JWT required for every API?

No. Choose the token format according to the architecture.

Is rate limiting sufficient for security?

No. It is only one layer of defence.

Can API key be kept in source code?

Production secrets must be managed outside of source code and repository.

Related articles

Combine Your Systems with Reliable Data Flow

Explore B10 Digital Agency’s API & System Integrations service to plan the integration architecture for ERP, CRM, marketplaces, custom software and third-party services.

Explore API & System Integrations →

Sources and related documents

These documents provide references for the methods and rules discussed in this article.

B10 Digital Agency

API Security: OAuth 2.0, Tokens, Rate Limiting and Authorisation