Parameters

  1. connectionQuery: string | { slug: string } | { id: string }
    The query to identify the connection, an object with either a slug property (the URL Slug of the connector as configured in your Xkit dashboard, e.g. slack) or an id property (the unique ID of the connection).

It is deprecated to use just a string parameter, which is interpreted as the URL slug of the connector.

Returns

Promise<string | null>
A Promise that resolves to a valid access token for the requested service or null.

getConnectionToken calls the getConnection API to maximize ease of use when retrieving access tokens specifically.

When you call this function, you'll either get an access token in the case that the connection is installed, active, and a valid access token exists, or you'll get nothing (specifically, null).

const slackToken = await xkit.getConnectionToken({ slug: "slack" })

if (slackToken) {
  // ... do something with the Slack API
}
const slackToken = await xkit.getConnectionToken({ id: "unique-id" })

if (slackToken) {
  // ... do something with the Slack API
}