OAuth vs API Key Authentication

Otesse supports two authentication methods for third-party integrations: OAuth 2.0 with PKCE and manual API key entry. The authentication type is determined by the provider — each provider in the catalog specifies which method it uses. This page explains how each method works, their security characteristics, and how credentials are managed.

OAuth 2.0 with PKCE

OAuth is the industry standard for delegated authorization. When a provider supports OAuth, the user authenticates directly with the provider (not through Otesse) and grants Otesse specific permissions (scopes) to access their account.

How OAuth Works

  1. State creation — The system generates a cryptographically random state token and a PKCE code verifier/challenge pair. These are stored in an OauthState record that expires after 10 minutes.
  1. Authorization redirect — The user's browser is redirected to the provider's authorization page with the following parameters:
ParameterDescription
client_idOtesse's application ID with the provider
redirect_uriCallback URL where the provider sends the user after authorization
response_typeAlways "code" (authorization code flow)
stateRandom token for CSRF protection
code_challengeSHA-256 hash of the code verifier (PKCE)
scopePermissions being requested
  1. User grants access — The user sees the provider's consent screen listing what Otesse is requesting access to. They click "Allow" or "Deny."
  1. Callback processing — The provider redirects back to Otesse with an authorization code. The system validates the state token, exchanges the code for access/refresh tokens using the PKCE code verifier, and stores the tokens encrypted.
  1. Health check — The system uses the new access token to make a test API call, verifying the connection works.

OAuth Security Features

FeaturePurpose
PKCE (Proof Key for Code Exchange)Prevents authorization code interception attacks
State tokenPrevents cross-site request forgery (CSRF)
10-minute expiryState tokens expire quickly to limit attack window
Single-use stateEach state token can only be used once
Server-side code verifierThe PKCE verifier is never sent to the browser

Token Lifecycle

OAuth connections involve two types of tokens:

TokenLifetimePurpose
Access tokenShort-lived (typically 1 hour)Used for API calls to the provider
Refresh tokenLong-lived (months or indefinite)Used to obtain new access tokens when the current one expires

When an access token expires, the system automatically attempts to refresh it using the refresh token. If the refresh fails (token revoked or expired), the connection status changes to "expired" and the user must re-authenticate.

API Key Authentication

API key authentication is simpler — the user manually enters their API key (and optionally an API secret or account ID) into a form. The key is encrypted and stored immediately.

How API Key Auth Works

  1. Form display — A modal shows input fields based on the provider's requiredCredentials configuration. Most providers need only an API key; some require additional fields.
  1. Credential entry — The user enters their credentials. All fields are masked (password-type inputs) to prevent shoulder surfing.
  1. Encryption — On submission, each credential is encrypted using AES-256-GCM with a key derived from the INTEGRATIONENCRYPTIONKEY environment variable.
  1. Storage — Encrypted credentials are stored in IntegrationCredential records. The plaintext is never logged, never stored in the database, and never included in API responses.
  1. Health check — The system decrypts the credentials and makes a test API call to verify they work.

API Key Security Features

FeaturePurpose
AES-256-GCM encryptionMilitary-grade encryption for stored credentials
Environment-derived keyEncryption key is not stored in the database
No plaintext storageCredentials exist in plaintext only during the encrypt/decrypt operation
No loggingCredential values are excluded from all logging
No API exposureCredential values are never returned in API responses

Comparison

AspectOAuth 2.0API Key
User experienceRedirect to provider, grant access, returnEnter key in a form
Credential ownershipProvider issues tokens; Otesse never sees the user's passwordUser copies key from provider dashboard
Token rotationAutomatic via refresh tokensManual (user must generate new key and re-enter)
Scope controlGranular — request only needed permissionsTypically all-or-nothing based on key type
RevocationCan revoke at the provider or in OtesseMust revoke at the provider and update in Otesse
ComplexityHigher (multiple redirects, PKCE, state management)Lower (single form submission)

Credential Types

Each stored credential is classified by type:

Type CodeDescriptionUsed With
oauthaccesstokenShort-lived OAuth access tokenOAuth providers
oauthrefreshtokenLong-lived token for refreshing accessOAuth providers
api_keyStatic API keyAPI key providers
client_idOAuth application client IDOAuth providers
client_secretOAuth application client secretOAuth providers
webhook_secretSigning secret for webhook verificationWebhook-enabled providers

Which Providers Use Which Method

Currently, all seven connected providers in Otesse use API key authentication. OAuth support is built into the platform for future providers like Salesforce, Google Calendar, and QuickBooks that require delegated authorization flows.

The authentication method is configured at the provider level and cannot be changed by organizations or users. When you connect a provider, the system automatically presents the correct authentication flow based on the provider's configuration.