- Your app already stores API keys or tokens for users
- You’re adopting Composio and want to onboard existing users without disrupting them
- You want to use bearer tokens with OAuth toolkits (Gmail, GitHub, Slack, etc.) without setting up an OAuth app
How it works
Prerequisites
- An auth config for the toolkit you’re importing into
- The existing credentials for each user (API keys, bearer tokens, username/password, etc.)
- A userID for each user. Any string that uniquely identifies them in your system.
API keys
For services that use API key authentication (e.g., SendGrid, Tavily, PostHog):- Python
- TypeScript
- API
Bearer tokens
If you manage your own OAuth flow and already have an access token for a service, you can import it into Composio as a bearer token. This lets you bring existing OAuth connections into Composio without re-authenticating your users. It works with all toolkits that support OAuth2 or S2S auth (Gmail, GitHub, Slack, Google Docs, and more). Any additional parameters the toolkit supports (e.g.,subdomain, base_url) work the same way.
Since you’re providing your own token, Composio won’t handle OAuth refresh. You’re responsible for refreshing the token on your end and pushing the updated value to Composio via the PATCH method whenever it changes.
After creating an auth config with authScheme: "BEARER_TOKEN", use the snippet below to create a connected account:
- Python
- TypeScript
- API
Basic auth
- Python
- TypeScript
- API
Updating credentials
When credentials expire or rotate, update them in place without recreating the connection. Fields you omit are preserved. Fields set tonull are removed.
- Bearer token
- API key
- Basic auth
- Python
- TypeScript
- API
Using in your session
Pass the auth config or connection ID when creating a session:- Python
- TypeScript
- API