OAuth Configuration

Secure OAuth 2.0 integration with automatic token management

MCPify provides comprehensive OAuth 2.0 support with secure credential storage, automatic token refresh, and complete isolation between tenants. Configure once, and let MCPify handle the complexity of OAuth flows.

Supported OAuth 2.0 Flows

Client Credentials Flow

Machine-to-machine authentication for server applications

{
  "upstreamAuth": {
    "type": "vault",
    "vault": {
      "provider": "<the provider registered for your API>",
      "principalKind": "service_account",
      "tenantId": "your-company",
      "userId": "your-company:your-api",
      "grantMode": "client_credentials"
    },
    "secrets": {
      "clientId": "your-api-client-id-secret-name",
      "clientSecret": "your-api-client-secret-secret-name"
    }
  }
}

Use for: Service accounts, backend integrations, automated workflows

Authorization Code Flow

One account, authorized once through the provider's consent and then used for the service

{
  "upstreamAuth": {
    "type": "vault",
    "vault": {
      "provider": "custom",
      "principalKind": "service_account",
      "tenantId": "your-company",
      "userId": "your-company:your-api",
      "grantMode": "authorization_code_refresh"
    }
  }
}

The config names no secrets: the refresh token from the consent is stored encrypted in the vault under that account, and MCPify holds the OAuth client details that refresh it.

Use for: Delegated access through one connected account

Refresh Token Management

Automatic token refresh with zero downtime

  • Automatic refresh before expiration
  • Concurrent request handling during refresh
  • Cooldown after a failed refresh, honoring the provider's Retry-After

Secure Credential Management

Credential Vault Architecture

All OAuth credentials are stored in MCPify's encrypted vault with multiple layers of security:

1

Encryption at Rest

AES-256-GCM encryption at rest with managed keys

2

Automatic Refresh

Tokens refreshed automatically, with refresh tokens stored as the provider rotates them

3

Access Control

Least-privilege service keys with audit logging

4

Multi-Tenant Isolation

Complete isolation between tenant credentials

How Credentials Reach the Vault

Once the integration is agreed, you submit the upstream credentials at credentials.mcpify.org, or your users connect their accounts through the provider's OAuth consent screen. Either way the credentials are stored encrypted in the vault and never appear in your service configuration or in a tool response.

Provider-Specific Configuration

Microsoft / Azure AD

{
  "upstreamAuth": {
    "type": "vault",
    "vault": {
      "provider": "microsoft",
      "principalKind": "service_account",
      "tenantId": "your-company",
      "userId": "your-company-account",
      "grantMode": "authorization_code_refresh"
    }
  }
}

Google

{
  "upstreamAuth": {
    "type": "vault",
    "vault": {
      "provider": "google",
      "principalKind": "service_account",
      "tenantId": "your-company",
      "userId": "your-company-account",
      "grantMode": "authorization_code_refresh"
    }
  }
}

Token Lifecycle Management

Token Acquisition

Initial token request with configured credentials and scopes

Token Storage

Encrypted storage with expiration tracking and metadata

Token Usage

Automatic injection into API requests with proper headers

Token Refresh

Proactive refresh before expiration with retry logic

Token Revocation

Clean revocation on logout or credential rotation

Security Best Practices

✅ Recommended

  • • Use PKCE for public clients
  • • Implement token rotation
  • • Use minimal required scopes
  • • Enable refresh token rotation
  • • Monitor token usage patterns
  • • Implement token binding
  • • Use short-lived access tokens

⚠️ Avoid

  • • Storing tokens in logs
  • • Using implicit flow
  • • Hardcoding credentials
  • • Sharing tokens between services
  • • Ignoring token expiration
  • • Disabling certificate validation
  • • Using long-lived tokens

Common Issues & Solutions

Invalid Grant Error

The provided authorization grant is invalid, expired, or revoked

Solution: Check refresh token validity, ensure correct redirect URI, verify client credentials, and confirm authorization code hasn't been used

Insufficient Scope

The access token doesn't have required permissions

Solution: Review required scopes, request additional permissions, check admin consent requirements, verify scope configuration

Token Expiration

Access token has expired during request

Solution: Enable automatic refresh, increase buffer time, implement retry logic, check clock synchronization

Related Documentation