Add an additional connection to a 3rd party service

🚧

Custom Catalogs Only

The addConnection method should only be used if you are building a custom catalog experience and you want to support more than one connection to a service per user. It is more common to use connect which is a simpler interface.

Parameters

  1. connector: Connector | string
    The Connector object for which a new Connection should be created, or a string slug of the Connector.

  2. id: string (optional)
    A unique identifier for this connection. The ID should be unique in the context of your entire platform and can be used to retrieve and modify this connection specifically.

If not supplied, an opaque unique identifier will be generated.

Returns

Promise<Connection>
A Promise that resolves to the newly created Connection.

addConnection kicks off an authorization sequence for the provided Connector which includes opening a pop-up window, collecting input from the user (e.g. consent to grant access to the 3rd party service), and finalizes the connection (e.g. by retrieving OAuth2 access tokens).

addConnection monitors both the opened popup window as well as a WebSocket connection with Xkit to provide instant feedback to the user in cases of errors and success.

In cases where the connection is successfully created, addConnection returns the newly created Connection object with the enabled attribute set to true.

In cases where the connection fails, addConnection will throw errors with descriptive messages as to the source of the error (e.g. Installation cancelled. if the user closes the pop-up without continuing).

const additionalSlackConnection = await xkit.addConnection("slack", "unique-id")
const additionalSlackConnection = await xkit.addConnection("slack")