Multiple Account Authorizations

Use the SDK to connect multiple accounts for the same integration.

Multiple Account Authorizations is a set of options for the Headless Connect Portal that enables you to connect multiple accounts for the same integration type for a user.

For example, one Connected User can connect a Google Calendar integration for both their Google Workspace account and personal Gmail account.

Usage

A subset of SDK functions can be passed an additional parameter for Multiple Account Authorizations, as outlined below.

In general, to use Multiple Account Authorizations, you will need to:

  • Use user.integrations.[integration name].allCredentials (a field returned in getUser) to display multiple connected accounts in your Integrations UI.

  • Update references to installIntegration and uninstallIntegration to use the SDK with Multiple Account Authorizations enabled.

  • Update references to paragon.request and paragon.workflow (and API equivalents) to make sure that a specific account is targeted for a given integration type.

App Events and Workflows do not need to be updated to support Multiple Account Authorizations.

Reference

.getUser() -> ParagonUser

Call .getUser to retrieve the currently authenticated user and their connected integration state.

With Multiple Account Authorizations, the getUser() method additionally returns allCredentials, an array of connected accounts for a given integration.

paragon.getUser();

{
  authenticated: true,
  userId: "xyz", // The user ID you specified in the signed JWT
  integrations: {
    salesforce: {
      enabled: true,
      allCredentials: [
        {
          id: "a5e995c2-7709-43fd-9cdf-f759faa52497",
          dateCreated: "2023-05-30T22:33:20.349Z",
          dateUpdated: "2023-05-30T22:33:20.349Z",
          projectId: "d1f142cd-1dfe-4d76-ab4c-8f64901a9c5c",
          integrationId: "8aaad9ff-5adb-433c-a17b-da093f9d4528",
          personaId: "30975f6a-c50c-4e74-914a-3eb700db8b05",
          config: { configuredWorkflows: { ... } },
          isPreviewCredential: false,
          providerId: "1223115691",
          providerData: {},
          status: "VALID",
          dateRefreshed: "2023-05-30T22:33:20.349Z",
          dateValidUntil: "2023-05-30T23:33:17.809Z",
          refreshFailureCount: 0,
          isRefreshing: false,
        },
      ],
      configuredWorkflows: {},
      credentialId: "a5e995c2-7709-43fd-9cdf-f759faa52497",
      credentialStatus: "VALID",
      providerId: "1223115691",
      providerData: {},
    },
    shopify: {
      enabled: false,
    },
  },
};

.installIntegration(integrationType: string, options?: IntegrationInstallOptions) -> Promise

  • Additional options: If allowMultipleCredentials is specified as true in the options object, this function will not throw an error if the user already has this integration installed.

paragon.installIntegration("googledrive", {
    allowMultipleCredentials: true
});

Replacing an account

You can replace one of your user's existing connected accounts with the selectedCredentialId property. This option replaces the underlying connected account, keeping their enabled workflows and settings intact.

paragon.installIntegration("googledrive", {
    allowMultipleCredentials: true,
    selectedCredentialId: "0d2cca60-268b-45f1-ac5e-af6aad403d8c"
});

.uninstallIntegration(integrationType: string, options?: IntegrationUninstallOptions) -> Promise

Call .uninstallIntegration() to disconnect an integration for the authenticated user.

  • Additional options: selectedCredentialId (SDK) or X-Paragon-Credential (API) can be used to select a specific account to uninstall.

paragon.uninstallIntegration("googledrive", {
    selectedCredentialId: "de06dea8-8680-483c-95ea-cfcf66582c96"
});

.request(integrationType: string, path: string, requestOptions: RequestOptions) → Promise

Call .request to send an API request to a third-party integration on behalf of one of your users.

  • Additional options: selectedCredentialId (SDK) or X-Paragon-Credential (API) can be used to select a specific account to use with the Proxy API.

await paragon.request('slack', '/chat.postMessage', {
	method: 'POST',
	body: {
		channel: 'CXXXXXXX0' // Channel ID,
		text: 'This message was sent with Paragon Connect :exploding_head:'
	},
	selectedCredentialId: "de06dea8-8680-483c-95ea-cfcf66582c96"
});

.workflow(workflowId: string, options: FetchOptions)

Call .workflow() to trigger a Paragon workflow that sends a custom response back to your app. Note: The workflow must be enabled and use a Request-type trigger.

  • Additional options: selectedCredentialId (SDK) or X-Paragon-Credential (API) can be used to select a specific account to trigger a workflow for. The Credential ID that is used will be recorded for viewing in Task History.

// Trigger the "Lead Created" workflow
await paragon.workflow("<workflow_id>", {
  body: {
    "email": "bowie@useparagon.com",
    "first_name": "Bowie",
    "last_name": "Foo"
  },
  selectedCredentialId: "de06dea8-8680-483c-95ea-cfcf66582c96"
});
  

Last updated