db:// remote table:
- API keys — a long-lived shared secret passed as
api_keyon connect. Works in every SDK. - OAuth 2.0 — short-lived bearer tokens obtained from your identity provider, refreshed automatically by the client.
API key
Pass the API key from your Enterprise tenant onconnect. This works with both the synchronous and asynchronous Python clients, as well as TypeScript and Rust.
Python
OAuth
The async Python client and the TypeScript client can obtain bearer tokens from an OIDC issuer and attach them to every request. Token acquisition, caching, and refresh are handled inside the client — your application code only provides the configuration.In Python, OAuth is supported through
lancedb.connect_async. The synchronous connect entry point continues to use API key authentication for db:// URIs. In TypeScript, lancedb.connect accepts oauthConfig directly.Supported flows
OAuthFlowType selects how the client acquires tokens:
| Flow | Python value | TypeScript value | When to use |
|---|---|---|---|
| Client Credentials | OAuthFlowType.CLIENT_CREDENTIALS | OAuthFlowType.ClientCredentials | Service-to-service / machine-to-machine. Requires a client ID and client secret registered with your identity provider. |
| Azure Managed Identity | OAuthFlowType.AZURE_MANAGED_IDENTITY | OAuthFlowType.AzureManagedIdentity | Workloads running on Azure compute (VMs, AKS, App Service, Container Apps). Tokens are fetched from the Azure IMDS endpoint, so no client secret is stored on the client. |
Configure OAuth
Build an OAuth config and pass it on connect. Useoauth_config in Python and oauthConfig in TypeScript.
Configuration reference
The same configuration is available in both SDKs. Python usessnake_case field names; TypeScript uses camelCase.
| Python field / TypeScript field | Required | Description |
|---|---|---|
issuer_url / issuerUrl | Yes | OIDC issuer URL or OAuth authority URL. For Azure, use https://login.microsoftonline.com/{tenant_id}/v2.0. |
client_id / clientId | Yes | Application / client ID registered with your identity provider. |
scopes | Yes | List of OAuth scopes to request. For Azure managed identity, provide exactly one scope or resource, for example ["api://your-app-id/.default"]. |
flow | No | Selects the OAuth flow. Defaults to Client Credentials. |
client_secret / clientSecret | Conditional | Required for Client Credentials. Redacted from the config’s repr (Python) and Debug output (TypeScript native binding) so it does not leak into logs. |
managed_identity_client_id / managedIdentityClientId | No | Client ID of a user-assigned managed identity. Only used with Azure Managed Identity; omit for system-assigned identities. |
refresh_buffer_secs / refreshBufferSecs | No | How many seconds before token expiry to proactively refresh. Defaults to 300. Keep this well below the token TTL — setting it greater than or equal to the TTL forces a refresh on every request. |