Direct Token Injection

Create source connections or trigger syncs by supplying OAuth 2.0 tokens directly.

Use case

If you embed Airweave inside your own product you might already manage OAuth 2.0 tokens for your users. In that case, you do not want to have to ask them to click through a second consent screen for Airweave. Airweave therefore allows you to provide existing tokens to Airweave directly, so that

  • Your service owns token storage and rotation.
  • Airweave consumes the tokens solely for data sync.
  • No additional user interaction required.

There are two common scenarios:

  1. Create a new source connection by sending the access token.
  2. Trigger a sync on an existing source connection using stored credentials.

The next sections walk you through both flows.

Create a source connection with your own tokens

Skip the OAuth 2.0 flow entirely by sending your own tokens in the POST /source-connections call. You are responsible for acquiring and storing these tokens, Airweave simply uses what you provide.

Creating a source connection with direct tokens looks like this:

1from airweave import AirweaveSDK
2from airweave.types import OAuthTokenAuthentication
3
4airweave = AirweaveSDK(api_key="YOUR_API_KEY", base_url="https://api.airweave.ai")
5
6source_connection = airweave.source_connections.create(
7 name="Asana connection",
8 short_name="asana",
9 readable_collection_id="my-collection-id",
10 authentication=OAuthTokenAuthentication(
11 access_token="YOUR_ACCESS_TOKEN",
12 ),
13 sync_immediately=True
14)

Trigger a sync

The run endpoint uses the stored credentials from the source connection. To use different credentials, create a new source connection with OAuthTokenAuthentication.
By default, Airweave uses the credentials obtained during the initial OAuth 2.0 handshake to run a data synchronization job.

Here is an example:

1from airweave import AirweaveSDK
2
3airweave = AirweaveSDK(api_key="YOUR_API_KEY", base_url="https://api.airweave.ai")
4
5job = airweave.source_connections.run(
6 source_connection_id="source_connection_id"
7)

Auth provider connections

Airweave also supports creating source connections through auth providers like Composio and Pipedream. Check out the Authentication Providers documentation to learn more.

If you have an edge case that isn’t covered by these features, please let us know at hello@airweave.ai.