Skip to main content

Connector Access Modes

Choose whose identity an agent's connectors run with: the signed-in user's own permissions, or the connector's stored credentials.​

Why Use Access Modes​

An agent connected to Snowflake, Databricks, or SharePoint normally runs every tool call with the connector's stored credentials. Every user who talks to the agent sees whatever those credentials can see. When the underlying system already enforces per-user permissions, you usually want the opposite: each caller limited to their own data.

Access modes make that a one-line choice per connection:

Backend code
await this.squid
.ai()
.agent('analyst')
.setAgentOptionInPath('connectedIntegrations', [
{
integrationId: 'snowflake-prod',
integrationType: 'snowflake',
description: 'The sales warehouse',
access: { mode: 'user' }, // run queries as the signed-in user
},
]);

With mode: 'user', Squid obtains an access token for the caller, and the connector's tools run with the caller's own permissions. A request that cannot produce a user token fails before any tool runs; it never falls back to the stored credentials.

Overview​

Every connected integration and connected knowledge base on an agent can carry an access field:

interface AiIntegrationAccess {
/**
* 'user': tools run as the signed-in user; the call fails when no user token can be obtained.
* 'integration': tools run with the connector's stored credentials; user tokens are ignored.
*/
mode: 'user' | 'integration';
/**
* In user mode, the auth integration whose signed-in user the tools run as.
* Defaults to the auth integration of the request's Authorization header.
*/
authIntegrationId?: string;
}

A connection without access follows its connector type's default:

ConnectorDefault without access
Snowflake, Databricks SQLUses a token the caller sends explicitly, otherwise the stored credentials. Never derives a token on its own.
Databricks GenieFollows the connector's auth mode: user auth runs as the user, service principal runs as the connector.
SharePoint, OneDrive, and Outlook in live modeAlways run as the signed-in user. integration mode is refused.
Azure AI SearchRuns as the signed-in user.
All other connectorsRun with the stored credentials and accept no user tokens.

Setting mode: 'user' on a connector that takes no user tokens is refused at save time, as is mode: 'integration' on one that runs only as the user.

note

Access modes are available in the TypeScript client SDK. The Python SDK authenticates with the app API key and carries no user sign-in, so an agent whose connections run in user mode fails with USER_TOKEN_REQUIRED when called from Python.

Quick Start​

Prerequisites​

  • An agent with a connected integration of a supported type (see the table above). The examples use a Snowflake connector with ID snowflake-prod.
  • Users sign in to your app through an auth integration, set on the client with setAuthProvider.
  • A deployed Squid backend, since changing a connection's access needs the app API key.

Step 1: Set the access mode on the connection​

Changing an agent's stored connections requires an API key, so do it from backend code:

Backend code
import { executable, SquidService } from '@squidcloud/backend';

export class AgentAccessService extends SquidService {
@executable()
async runSnowflakeAsUser(): Promise<void> {
// Update only this connection's access, leaving the rest of the agent unchanged.
await this.squid
.ai()
.agent('analyst')
.setAgentOptionInPath('connectedIntegrations[integrationId=snowflake-prod].access', {
mode: 'user',
});
}
}

Step 2: Call the agent with a user token​

The simplest way to supply the user's identity is to send an access token for the connector with the request. Tokens ride in integrationAccessTokens, keyed by the connector's integration ID:

Client code
// snowflakeToken: an OAuth access token your app obtained for the user,
// accepted by the Snowflake account's External OAuth integration.
const response = await squid
.ai()
.agent('analyst')
.ask('What were my region sales last quarter?', {
integrationAccessTokens: { 'snowflake-prod': snowflakeToken },
});

A token sent for a connector always wins over anything Squid would derive. Alternatively, configure a derivation (next section) and Squid builds the token from the caller's sign-in automatically, so the frontend passes nothing extra.

Where the User Token Comes From​

For each tool call of a user-mode connection, Squid resolves a token in this order:

  1. A token sent for the connector: integrationAccessTokens[integrationId] on the request.
  2. Derived from the sign-in: Squid verifies the request's sign-in (the Authorization bearer set by setAuthProvider, or a pinned sign-in, see below) and exchanges it for a token the connector accepts.

There are four derivation paths:

Microsoft Entra ID on-behalf-of​

When users sign in with a Microsoft Entra ID auth integration, Squid can exchange the sign-in token on behalf of the user. Add the optional Client Secret (for token exchange) to the Entra ID auth integration in the Console; it is a secret of the same app registration users sign in with.

Targets: Azure Databricks (SQL and Genie), Azure AI Search, and Snowflake (with User Token Source set to exchange and User Token Scope set, for example api://<app>/session:scope:analyst).

RFC 8693 token exchange​

For non-Entra sign-ins, the Auth0, Okta, Keycloak, and JWT RSA auth integrations take an optional Token Exchange configuration that names the provider endpoint Squid exchanges sign-ins at:

FieldMeaning
Token EndpointThe provider's OAuth token endpoint. HTTPS only, on a public host.
Client IDThe provider application allowed to perform token exchange.
Client SecretIts client secret, stored as a Squid secret.
Client AuthenticationHow Squid authenticates at the endpoint: basic (default) or post.
Subject Token TypeThe subject_token_type sent. Defaults to the access token type; Auth0 needs its profile's custom type.
Requested Token TypeThe requested_token_type sent, when the provider requires one.

Target: Snowflake with User Token Source exchange. The User Token Audience and User Token Scope on the Snowflake connector become the exchange's audience and scope.

Databricks token federation​

Databricks workspaces can exchange any JWT sign-in themselves at the workspace's token endpoint. This needs a token federation policy on the workspace and no configuration in Squid. It applies only to Databricks-owned workspace hosts. On Azure, an Entra sign-in whose auth integration has the exchange client secret uses on-behalf-of instead.

Pass-through​

The sign-in token itself is used, with no exchange:

  • SharePoint, OneDrive, and Outlook in live mode (Entra ID sign-ins only; the connector performs its own Microsoft Graph exchange).
  • Snowflake with User Token Source signIn, when the Snowflake account's External OAuth integration trusts the sign-in's issuer.

Pinning a Different Sign-In​

By default, user mode reads the request's own sign-in. When an agent serves callers who sign in with one provider but a connector needs an identity from another, pin the connection to a specific auth integration and send that second sign-in with the request, keyed by the auth integration's ID:

Backend code
await this.squid
.ai()
.agent('analyst')
.setAgentOptionInPath('connectedIntegrations[integrationId=snowflake-prod].access', {
mode: 'user',
authIntegrationId: 'entra-id', // verify the token below with this auth integration
});
Client code
const response = await squid
.ai()
.agent('analyst')
.ask('Show my open orders', {
// A second sign-in, verified by the 'entra-id' auth integration.
integrationAccessTokens: { 'entra-id': entraSignInToken },
});

Squid verifies the pinned sign-in with that auth integration before deriving anything from it.

Knowledge Bases​

Connected knowledge bases take the same access field. It applies to knowledge bases whose external source trims documents by the caller's token, such as an Azure AI Search index with native ACLs: searches then run with the caller's token, and each user only retrieves documents they can read at the source. Such a knowledge base runs only as the user; integration mode on it is refused.

Agents Exposed over MCP​

An agent exposed as an MCP server verifies each MCP caller's bearer token with the server's auth integration. That verified sign-in serves user-mode connections automatically, so MCP callers need to send nothing extra. An agent API key is not a sign-in and does not satisfy user mode.

Validation and Precedence​

Squid checks access settings when a connection is saved, before each turn builds its tools, and on every agent-tools MCP call:

  • user mode on a connector that accepts no user tokens, or integration mode on one that runs only as the user, is refused.
  • authIntegrationId must name an existing auth integration.
  • Two connections to the same source with different access settings are refused: at save time with CONNECTION_ACCESS_CONFLICT, and at chat time or on an MCP call with IDENTITY_CONFIGURATION_ERROR.
  • A request made without the app API key can only tighten a stored connection's access, never loosen it. A per-request connection is held to the strictest access stored for that source.
  • A turn whose main, backup, or advisor model is a CLI agent model (Claude Code, Codex) is refused with CLI_MODEL_UNSUPPORTED_USER_ACCESS when any connection of the turn runs as the user, because CLI models receive the app's secrets.

Error Handling​

Identity failures end the request before the tool runs. For the first three codes below, the error's errorType carries the code and its message is a JSON string with code, message, and the integrationId involved. The last two surface differently: CLI_MODEL_UNSUPPORTED_USER_ACCESS is a plain error whose message starts with the code, and ACCESS_TOKEN_REJECTED reaches the agent as a tool failure rather than ending the request.

CodeMeaning
USER_TOKEN_REQUIREDNo token was sent and none could be derived: the caller is not signed in, the connector-type default found no exchange to use, or the target trusts only Entra ID sign-ins. Send a token in integrationAccessTokens, or sign in with the right provider. On a connection with an explicit access: { mode: 'user' }, a missing exchange setup raises IDENTITY_CONFIGURATION_ERROR instead.
USER_AUTH_REQUIREDThe sign-in was rejected or expired, or the provider requires a fresh sign-in. Have the user sign in again.
IDENTITY_CONFIGURATION_ERRORThe configuration is wrong: a pinned ID that is not an auth integration, a missing token exchange client secret, a non-Databricks host, or a provider that rejected the exchange. Fix the configuration in the Console.
CLI_MODEL_UNSUPPORTED_USER_ACCESSThe turn uses a CLI agent model together with a user-mode connection or a sent token. Use a different model, or integration mode.
ACCESS_TOKEN_REJECTEDSnowflake refused the token at sign-in; the failure reaches the agent as a tool error. Check the account's External OAuth integration and the token's user and role.
Client code
try {
await squid.ai().agent('analyst').ask('What were my region sales last quarter?');
} catch (error: any) {
if (error.errorType === 'USER_TOKEN_REQUIRED' || error.errorType === 'USER_AUTH_REQUIRED') {
// Send the user through your sign-in flow, then retry.
await redirectToSignIn();
} else {
throw error;
}
}

Debugging tips:

  • An exchanged token is cached until the sign-in expires, so a token the target rejects can stay rejected until the user signs in again with a fresh token.
  • The app API key is not a sign-in. Backend calls to an agent with user-mode connections fail with USER_TOKEN_REQUIRED unless they send a token explicitly.
  • A connector reached through a squidlet cannot run in user mode.

Best Practices​

  • Let user mode fail closed. A user-mode connection never falls back to stored credentials, so a misconfigured exchange surfaces as an error instead of a data leak. Treat USER_TOKEN_REQUIRED in production as a sign-in or configuration problem, not something to catch and retry with wider access.
  • Prefer derivation over sending tokens. When the sign-in provider can exchange tokens, the frontend passes nothing extra and tokens never transit your application code.
  • Scope exchange clients narrowly. The token exchange client at your provider should be allowed to exchange only for the audiences your connectors need.
  • Pin a sign-in deliberately. authIntegrationId is for the two-provider case. When the request's own sign-in is the right identity, leave it unset.
  • Keep integration mode for shared data. Dashboards over data every caller may see run cheaper and simpler with stored credentials.