Skip to navigation

Direct Token Injection

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

Use case

If you embed Interlace 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 Interlace. Interlace therefore allows you to provide existing tokens to Interlace directly, so that

  • Your service owns token storage and rotation.
  • Interlace 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, Interlace simply uses what you provide.

Creating a source connection with direct tokens looks like this:

from interlace import InterlaceSDK
from interlace.types import OAuthTokenAuthentication
interlace = InterlaceSDK(api_key="YOUR_API_KEY", base_url="https://api.useinterlace.com")
source_connection = interlace.source_connections.create(
name="Asana connection",
short_name="asana",
readable_collection_id="my-collection-id",
authentication=OAuthTokenAuthentication(
access_token="YOUR_ACCESS_TOKEN",
),
sync_immediately=True
)

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, Interlace uses the credentials obtained during the initial OAuth 2.0 handshake to run a data synchronization job.

Here is an example:

from interlace import InterlaceSDK
interlace = InterlaceSDK(api_key="YOUR_API_KEY", base_url="https://api.useinterlace.com")
job = interlace.source_connections.run(
source_connection_id="source_connection_id"
)

Auth provider connections

Interlace 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@useinterlace.com.