This guide shows you how you can implement a custom connection UI
1. Get Auth Options
To get information about what to ask the user in order to create a connection, fetch connection options:For simplicity, we’ll assume there is only one auth option. If there are more, you can use the same logic for each of them. If there are zero options, it means authentication is not configured and you need to edit or change the connector. Each connection option contains:
key– Unique identifier for this auth option (pass toauthOptionKeywhen connecting)type– The authentication type (e.g., ‘oauth2’, ‘client-credentials’)title– Human-readable name for this auth optiondescription– Description explaining this auth methodinputSchema– Data Schema of the parameters required to create a connection. It will be empty if parameters are not required.
2. Connection Parameters UI
You can use your preferred way of converting JSON Schema into a form. For example, you can extract a list of fields from the schema and simply display an input for each:If a connection doesn’t have parameters, you can skip this step.
3. Creating a Connection
When you have collected connection input, you can create a connection:
This code may open a new window if it is required by the authentication process.
Make sure this code runs inside a user action handler (e.g. onClick), otherwise the browser may block the new window.
Redirect instead of a new window When you need to avoid opening a new window, you can use redirect instead. Pass
sameWindow: true and redirectUri options. The URI will be used for redirection after the connection is created or fails.
Added query parameters:
- For successful creation, the
connectionIdwill be added - For failures,
errorwill contain the error message anderrorDatawill contain the JSON stringified error payload
4. Putting it all together
Here is a simple UI component that displays the connection parameters and creates a new connection:5. Re-connecting
When a connection becomes disconnected, you can re-connect it using the same code as when creating a new connection:Multiple Connections for the same Integration
If you want to let your tenants create multiple connections for the same integration, set theallowMultipleConnections option of the connect method call to true.