Predefined Connection
Use predefined connections to allow users to access your piece in the embedded app without re-entering authentication credentials.
The high-level steps are:
- Create a global connection for a project using the API in the platform admin. Only platform admins can edit or delete global connections.
- (Optional) Hide the connections dropdown in the piece settings.
Prerequisites
- Run the Enterprise Edition
- Create your piece. Later we will customize the piece logic to use predefined connections.
Create a Predefined Connection
Create an API Key
Go to Platform Admin → Security → API Keys and create an API key. Save it for use in the next step.
Create a Global Connection via API
Add the following snippet to your backend to create a global connection each time you generate the JWT token.
The snippet does the following:
- Create Project If it doesn’t exist.
- Create a global connection for the project with certain naming convention.
Implementation:
Hide the Connections Dropdown (Optional)
Modify Trigger / Action Definition
Wherever you call createTrigger
or createAction
set requireAuth
to false
, this will hide the connections dropdown in the piece settings in the builder,
next we need to fetch it based on a naming convention.
Fetch the connection
Here is example how you can fetch the connection value based on naming convention, make sure this naming convention is followed when creating a global connection.