Storing Connection Tokens
After configuring a Connection in Descope, you can start storing tokens for your users or tenants to access third-party APIs.
This section covers how to store tokens for OAuth-based connections or API key-based connections, for both user-scoped and tenant-scoped tokens.
For information on how to fetch connection tokens after they've been stored, see the Fetching Connection Tokens documentation.
Connections can store multiple tokens for the same user or tenant, each with different scopes.
Once you've created a Connection, you can start storing tokens for your users or tenants to access third-party services through Descope Connections.
Storing User Tokens
For user-scoped tokens, you can store tokens using either OAuth-based connections or API key-based connections.
OAuth Provider Connections
For OAuth-based connections (e.g., Google, Microsoft, Salesforce), you can store user tokens using either Adaptive Connect or Descope Flows.
OAuth Connections: Adaptive Connect
Adaptive Connect allows your MCP server to dynamically request connection permissions when a tool requires external OAuth tokens that the user hasn't yet granted. Instead of failing immediately, your MCP server can return a connection URL to the MCP client, prompting the user to grant the necessary permissions.
Adaptive Connect is specifically designed for MCP servers where tools need to request connections on-demand. For traditional web applications, use Descope Flows instead.
When an MCP tool requires a connection token that doesn't exist or lacks the required scopes, Adaptive Connect enables your server to:
- Detect the missing token when attempting to fetch a connection token
- Request a connection URL from Descope
- Return the connection URL to the MCP client in a structured response
- Allow the user to grant permissions via the OAuth flow
- Retry the tool execution after the connection is established
The simplest implementation pattern is to catch token fetch failures and return a connection URL in the error response. This is shown in the Complete Example below.
Connection Endpoint
The Adaptive Connect endpoint allows you to request a connection URL for a specific connection.
Request Parameters
appId(required): The ID of the connection you want to connect to.options(optional): Additional options for the connection request.redirectUrl(required): The URL where the user will be redirected after successfully completing the OAuth flow. This must be a valid URL that your application can handle.
Response
The endpoint returns a JSON object with a url field containing the OAuth authorization URL that the user should be redirected to, such as:
Complete Example
Here's a complete example showing how to implement Adaptive Connect in an MCP tool. This example demonstrates the tool elicitation pattern, where the MCP server detects a missing connection token, requests a connection URL, and returns it in a structured response that MCP clients can handle gracefully:
OAuth Connections: Using Descope Flows
For traditional web applications or when you want to collect OAuth connections during the initial login flow, use Descope Flows with OAuth-specific actions.
If you're using Descope Flows, you must first sign in using the flow before you can connect to a connection. The authenticated session will be used to establish a connection and associate the connection tokens with the respective user.
Flow Components for OAuth Connections
There are two main components for OAuth connections:
- Outbound App Button - A button component that initiates the OAuth connection
- Outbound App Connect Action - The action that processes the OAuth connection request
- Outbound App / Connect (user-level) - For user-scoped OAuth tokens
![]()
Implementation Options
You can implement OAuth connections in flows in two ways:
Option 1: Using the Outbound App Button
Place an Outbound App button on your flow screen that users can click to initiate the OAuth connection. The button can be customized with text and styling options, and it automatically displays the connection's logo.
Option 2: Using the Connect Action Directly
If you want to use your own UI elements, you can trigger the Outbound App Connect action directly from your application. You can set a default connection in the action's configuration to bypass the need for Descope's UI components.
In addition to this, you can also configure custom scopes that will override the default scopes configured in your Connection Settings.
![]()
Descope manages the OAuth consent flow, token storage, and automatic token refresh.
API Key Connections
For services that use static API keys (e.g., custom APIs, services without OAuth), you can collect and store API keys for users using Descope Flows.
Note
Currently, you cannot store API keys with Connections directly via a REST API. You must use Descope Flows.
API Key Connections: Using Descope Flows
API key connections use different flow actions than OAuth connections:
Flow Components for API Key Connections
Use this action in your Descope Flow:
- Outbound App / Connect API Key (user-level) - Collects and stores an API key for a specific user
Implementation
The process is similar to OAuth connections:
- Add the appropriate API key connect action to your flow
- The action renders a secure input screen for users to submit their API key
- Once submitted, the API key is stored securely in the Connection vault
- The API key becomes available to your MCP server or backend for tool execution
For machine-to-machine agents or backend automation, API keys can also be inserted programmatically via SDK or API without user interaction, depending on your integration design.
Storing Tenant Tokens
For tenant-scoped tokens, you can store tokens using either OAuth-based connections or API key-based connections.
OAuth Provider Connections
For OAuth-based connections (e.g., Google, Microsoft, Salesforce), you can store tenant tokens only using Descope Flows.
OAuth Connections: Using Descope Flows
For traditional web applications or when you want to collect OAuth connections during the initial login flow, use Descope Flows with OAuth-specific actions.
If you're using Descope Flows, you must first sign in using the flow before you can connect to a connection. The authenticated session will be used to establish a connection and associate the connection tokens with the respective tenant.
Flow Components for OAuth Connections
There are two main components for OAuth connections:
- Outbound App Button - A button component that initiates the OAuth connection
- Outbound App Connect Action - The action that processes the OAuth connection request
- Outbound App / Tenant Connect - For tenant-scoped OAuth tokens
![]()
Implementation Options
You can implement OAuth connections in flows in two ways:
Option 1: Using the Outbound App Button
Place an Outbound App button on your flow screen that users can click to initiate the OAuth connection. The button can be customized with text and styling options, and it automatically displays the connection's logo.
Option 2: Using the Connect Action Directly
If you want to use your own UI elements, you can trigger the Outbound App / Tenant Connect action directly from your application. You can set a default connection in the action's configuration to bypass the need for Descope's UI components.
In addition to this, you can also configure custom scopes that will override the default scopes configured in your Connection Settings.
![]()
Descope manages the OAuth consent flow, token storage, and automatic token refresh.
API Key Connections
For services that use static API keys (e.g., custom APIs, services without OAuth), you can collect and store API keys for tenants using Descope Flows.
Note
Currently, you cannot store API keys with Connections directly via a REST API. You must use Descope Flows.
API Key Connections: Using Descope Flows
API key connections use different flow actions than OAuth connections:
Flow Components for API Key Connections
Use this action in your Descope Flow:
- Outbound App / Connect Tenant API Key - Collects and stores an API key for a tenant
Implementation
The process is similar to OAuth connections:
- Add the appropriate API key connect action to your flow
- The action renders a secure input screen for users to submit their API key
- Once submitted, the API key is stored securely in the Connection vault
- The API key becomes available to your MCP server or backend for tool execution
For machine-to-machine agents or backend automation, API keys can also be inserted programmatically via SDK or API without user interaction, depending on your integration design.
Deleting Connection Tokens
Once you've created your tokens, if you wish to delete them, you can remove these connection tokens in two ways:
1. Using the Descope Console
Navigate to the Token Management tab for your connection in the Descope Console. Find the user or tenant whose token you want to delete, and use the delete option in the dashboard (see image above).
2. Using our SDKs / APIs
You can also delete tokens programmatically using our SDKs / APIs:
Delete a Specific Token by ID
Delete Tokens by App ID and/or User ID
You can delete tokens by providing an app ID, user ID, or both. At least one of appId or userId must be provided.