| Author: Abdullah Ahmed | Category: API Development and Integration
A supplier asks how it should authenticate to your API. One developer suggests an API key, another recommends OAuth, and a third says the application already uses JWTs. These answers can sound like competing choices even though they describe different parts of an access design.
An API key is a credential pattern. OAuth is a framework for obtaining delegated or application access. A JSON Web Token is a format for carrying claims. A session is a way to maintain an authenticated interaction across requests. A single system may use several of these together for different callers.
Choosing responsibly starts with the caller, the trust boundary and the action being permitted. A server-to-server reporting job has different needs from a customer using a browser or an external application acting with a user's consent. The following explanation is a planning guide for those distinctions, not a substitute for reviewing a concrete implementation.
Separate identity from permission
Authentication establishes or verifies an identity or credential context. Authorisation decides whether the caller may perform an action on a particular resource. Passing an authentication check should not automatically grant access to every record the API can return.
Consider a customer portal. The service may recognise a valid session, yet it must still ensure the customer can see the requested order. Changing an order identifier in a URL should not bypass that decision. The same requirement applies to searches, exports and bulk operations.
Define the principal the API is acting for. It may be a person, an application, an organisation or a combination of those. Record how that context reaches the resource service and where the actual business permission is evaluated.
This separation helps procurement discussions too. A supplier saying it supports OAuth has not answered whether your integration can be restricted to one account or a narrow operation. Ask about the access model as well as the credential mechanism.
Understand what an API key identifies
An API key commonly identifies a calling application or integration. The provider issues a value that the client presents according to the documented interface. Some keys are secret credentials; others are intended as public project identifiers and need additional restrictions. Determine which kind the provider supplies.
For a confidential server integration, a secret key can be a straightforward mechanism when its access is appropriately limited and the service supports a manageable lifecycle. Its simplicity does not remove the need for secure storage, transport and revocation.
Do not embed a secret key in a downloadable mobile application or browser bundle and assume it remains private. Code delivered to the caller's device is not a dependable secret store. If the provider supports a public key for such a client, understand the restrictions and the operations it actually authorises.
Issue separate credentials for distinct integrations and environments where supported. This makes it easier to investigate use and revoke one connection without disabling unrelated work. Avoid sharing a single production key across several suppliers merely because it is convenient initially.
Evaluate the lifecycle of a key
Ask how a key is created, delivered, stored, rotated and revoked. Those operations determine whether the mechanism remains manageable after the first successful request. A key that cannot be replaced without an extended outage may create an avoidable operational dependency.
Limit its privileges to the integration's job. A reporting process should not automatically receive permission to modify customer records. Check whether restrictions apply to operations, resources, accounts or other relevant boundaries.
Keep credentials out of URLs, source repositories and routine diagnostic output. Logging the entire request header can expose a secret even when the transport is encrypted. Configure diagnostics to retain useful context without retaining reusable credentials.
Document what staff should do if a key is suspected to be exposed. The response needs an owner, a revocation route and a way to update the legitimate integration. Security controls become more useful when the team can actually operate them under pressure.
Recognise OAuth as an access framework
OAuth 2.0 defines roles and flows through which a client obtains access to protected resources. It can support an application acting with a user's authorisation and, in suitable confidential-client scenarios, an application obtaining access on its own behalf.
In a delegated example, an accounting application asks a user to authorise limited access to another service. The user interacts with the authorisation service, and the client obtains an access token under the selected flow. The client does not need the user's password for the resource service.
The value is the explicit relationship between client, authorisation service and resource access. The implementation still needs correct configuration, token handling and resource-level permission checks. OAuth does not automatically understand your organisation's order ownership rules.
Use the provider's supported flows and maintained libraries rather than improvising a protocol. Confirm the client type, redirect behaviour and available access scopes. A browser-based public client and a confidential backend cannot safely be treated as identical credential holders.
Use an appropriate modern OAuth flow
RFC 9700, published in January 2025, updates OAuth security guidance. It requires PKCE for public clients using the authorisation-code flow, recommends it for confidential clients, and rejects use of the resource-owner password credentials grant. Follow the applicable guidance and the provider's supported configuration when designing a new integration.
For planning purposes, PKCE helps bind the code exchange to the client instance that initiated it. The team should still review redirect validation and the other protections required by the selected flow. Adding one mechanism does not make every surrounding configuration safe.
Clarify whether the task is delegated user access or machine-to-machine work. A scheduled integration should not depend on an employee repeatedly approving interactive access unless that is a deliberate supported model. Conversely, application credentials should not silently substitute for a user's limited permission.
Test the complete lifecycle in the provider's environment. Include denied authorisation, expired access, revoked permission and an unavailable authorisation service. Those cases determine how the product behaves after the initial connection succeeds.
Keep login and delegated access distinct
OpenID Connect adds an identity layer on top of OAuth 2.0. It provides a defined way for a client to obtain information about an authenticated user. An OAuth access token and an OpenID Connect ID token have different purposes and should not be treated as interchangeable API credentials.
When a product offers external sign-in, ask which protocol establishes the user's identity and how the local account is linked. The resource API may still require a separate access token with the appropriate audience and permissions.
Plan account linking and recovery carefully. A matching display name is not a reliable identity relationship. Changes to email addresses or organisation membership should follow an explicit policy rather than an assumption embedded in an integration callback.
For a business stakeholder, the useful question is whether the implementation can explain who signed in, which local account that identity maps to and what access follows. The presence of a familiar sign-in button does not answer those questions on its own.
Understand what a JWT does and does not provide
RFC 7519 defines JSON Web Tokens as a compact representation of claims. JWTs may be protected using signatures or message authentication codes, or encrypted. A signed JWT's readable payload is not made confidential merely by its signature.
A JWT can be used as an access token, but the format is not an authentication flow by itself. The system still needs a trusted issuer, a process for obtaining the token and rules for deciding where it is valid. OAuth access tokens do not have to be JWTs.
Avoid placing unnecessary sensitive information in a token. Tokens pass through components and may be retained longer than expected if diagnostics are configured poorly. Keep the claims limited to what the recipient needs and handle the complete token as a credential where possession grants access.
Do not accept a token simply because it decodes successfully. Decoding reveals a structure; validation establishes whether the service should trust it. The distinction matters when teams discuss a JWT as though its shape alone proves authenticity.
Validate claims in the receiving service
JWT Best Current Practices, RFC 8725, addresses validation risks including algorithm choices and confusion between token uses. Configure accepted algorithms and keys deliberately, validate the expected issuer and audience, and apply the token profile's required time and claim checks.
The audience identifies the intended recipient context. A token valid for one API should not automatically be accepted by another. Keep validation rules specific enough that a token created for a different purpose cannot accidentally cross the boundary.
Plan signing-key rotation with the issuing system. The resource service needs a safe method to obtain trusted verification keys and handle changes. A key lookup should not become an unbounded opportunity to fetch arbitrary locations supplied by an untrusted token.
Business authorisation remains necessary after token validation. A claim may establish an account or role, but the API still needs to evaluate whether the requested record and action are permitted under current rules.
Compare opaque sessions with token-based access
In a common browser session design, the server maintains session state and the browser carries an opaque identifier, usually in a cookie. The identifier lets the server associate later requests with the established interaction. The browser does not need to carry the full user record.
A session can be a suitable choice for a first-party web application whose backend controls the interaction. It provides a natural place to manage active login state. Distributed hosting still needs a deliberate approach to the session store and its availability.
OWASP's Session Management Cheat Sheet describes protections including secure cookie attributes, session identifier renewal and timeout handling. Cookie-based authentication also needs appropriate protection against cross-site request forgery; cookie settings should be part of a complete design rather than the only defence.
A session is not inherently obsolete because another system uses JWTs. Compare the actual client and trust model, revocation needs and operating complexity. Choosing a token format for fashion can add work without improving the user's experience or the service's security.
Design expiry and revocation around real use
Decide how long access should remain valid and what happens when it expires during a task. The user may need to sign in again, or a confidential integration may obtain new access through its supported flow. Preserve safe work where appropriate and explain the required action.
Revocation behaviour depends on the mechanism and deployment. A server-controlled session can be invalidated in its store. A locally validated self-contained token may remain acceptable until expiry unless the system adds another check or revocation mechanism. Understand the actual design before promising immediate access removal.
Refresh tokens deserve careful handling because they can extend access. Restrict them to the appropriate client context and use the provider's protection and rotation mechanisms. Do not treat them as ordinary application preferences that can be copied into logs or shared configuration files.
Test staff departure and supplier disconnection as business scenarios. Confirm that the intended access stops and that unrelated integrations continue to work. Document any delay or additional action required so administrators have an accurate expectation.
Review access with a small set of business scenarios
An access review is easier to follow when each test describes a legitimate task and a boundary. Start with a customer reading their own order, a supplier retrieving only its assigned work and an administrator removing an integration. The team should explain both the successful path and the access that must remain unavailable.
For each scenario, record the caller, credential issuer, receiving service and permission decision. This can be a small diagram or table. The exercise often reveals where one component assumes another has already checked ownership, leaving the actual decision unclear.
Then test a change in the business relationship. A supplier loses access to an account, a user leaves an organisation or a session expires while a draft is open. Observe whether the result matches the intended policy and whether the person receives an understandable next step.
Ask support to investigate one rejected request using the available diagnostics. They should be able to connect it to the relevant integration or account without obtaining the reusable credential from the user. If the only debugging process requires copying live tokens into a shared conversation, improve the diagnostics before relying on that process.
Capture the result in the operating documentation. Include the access-removal procedure and any propagation delay the design deliberately allows. Administrators should not promise an immediate cutoff if a component can continue accepting an existing token for a defined period.
These scenarios do not replace a technical security review, but they make its business assumptions visible. They help the product owner judge whether the selected mechanisms support the relationships the service actually needs, and they give engineers concrete behaviour to verify when configuration or identity providers change.
Match the choice to the caller
| Caller | Possible approach | Question to resolve |
|---|---|---|
| First-party browser application | Server-managed session | How are cookies, CSRF and logout handled? |
| Confidential scheduled integration | Scoped key or supported OAuth application flow | How are credentials rotated and access limited? |
| Third-party application acting for a user | Supported OAuth delegated flow | How does the user grant and revoke access? |
| API receiving JWT access tokens | Validation of the agreed token profile | Which issuer, audience and claims are trusted? |
These are discussion starting points, not interchangeable presets. Provider capabilities and the application's threat model determine the final configuration. Some systems will combine a browser session, delegated OAuth access and a JWT-formatted token across different boundaries.
Before choosing a mechanism, draw the path from caller to protected resource and name the identity, credential and permission check at each step. Then demonstrate expiry, revocation and access to the wrong resource. A design that explains those cases clearly is easier to assess than a decision based on the most familiar acronym.