Skip to content

Commit ac6366e

Browse files
cherry picked changes from new docs
1 parent b18464a commit ac6366e

File tree

7 files changed

+209
-34
lines changed

7 files changed

+209
-34
lines changed

docs-v2/pages/connect/_meta.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,20 @@
1010
},
1111
"api": {
1212
"title": "API & SDK Reference"
13+
},
14+
"tokens": {
15+
"title": "Connect tokens"
16+
},
17+
"environments": {
18+
"title": "Environments"
19+
},
20+
"oauth-clients": {
21+
"title": "OAuth Clients"
22+
},
23+
"webhooks": {
24+
"title": "Webhooks"
25+
},
26+
"connect-link": {
27+
"title": "Connect Link"
1328
}
1429
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Connect Link
2+
3+
Connect Link provides a Pipedream-hosted link that lets you connect third-party accounts without any frontend implementation in your app.
4+
5+
## When to use Connect Link
6+
7+
If you aren't able to execute JavaScript or open an iFrame in your frontend, or you want to send users a URL to connect accounts via email or SMS, use Connect Link. That URL opens a Pipedream-hosted page that guides the user through the account connection flow. The URL is scoped to the specific end user, and expires after 4 hours.
8+
9+
## How to generate a link
10+
11+
See [the Connect quickstart](/connect/quickstart) for a full tutorial for getting Connect up and running.
12+
13+
Here's a quick overview of how to generate a Connect Link URL:
14+
15+
1. First, [generate a token](/connect/quickstart/#generate-a-token) for your users.
16+
2. Extract the `connect_link_url` from the token response.
17+
3. Before returning the URL to your user, add an `app` parameter to the end of the query string:
18+
19+
```
20+
https://pipedream.com/_static/connect.html?token={token}&connectLink=true&app={appSlug}
21+
```
22+
23+
4. Redirect your users to this URL, or send it to them via email, SMS, and more.
24+
25+
**To test this code, check out this workflow:**
26+
[https://pipedream.com/new?h=tch_EvfbvQ](https://pipedream.com/new?h=tch_EvfbvQ)
27+
28+
## Success and error redirect URLs
29+
30+
When you [generate a Connect link](/connect/quickstart/#how-to-generate-a-link), you can specify `success_redirect_url` and `error_redirect_url` parameters. Pipedream will redirect the end user to these URLs after they complete the connection flow, or if an error occurs. [See the API docs](/connect/api#create-a-new-token) for details.
31+
32+
In the absence of these URLs, Pipedream will redirect the user to a Pipedream-hosted success or error page at the end of the connection flow.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Environments
2+
3+
Pipedream Connect projects support two environments: `development` and `production`.
4+
5+
1. Connected accounts and credentials stored in `development` remain separate from `production`.
6+
2. In `development`, you can use the official Pipedream OAuth apps, so you can test integrations without creating your own OAuth client.
7+
8+
## How to specify environment
9+
10+
You specify the environment when [creating a new Connect token](/connect/api/#create-a-new-token) with the Pipedream SDK or API. By default, the enviromment is set to `production`. When users succesfully connect their account, Pipedream saves it for that `external_user_id` in the specified `project_environment`.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Image from 'next/image'
2+
import Callout from '@/components/Callout'
3+
4+
# OAuth Clients
5+
6+
When connecting an account for any OAuth app via Pipedream Connect, we'll default to using Pipedream's official OAuth client, which enables you to quickly get up and running. [Read more about OAuth clients in Pipedream here](/connected-accounts/oauth-clients).
7+
8+
## Using Pipedream OAuth
9+
10+
There are two types of apps in Pipedream:
11+
12+
1. **Key-based**: These apps require static credentials, like API keys. Pipedream stores these credentials securely and exposes them via API.
13+
2. **OAuth**: These apps require OAuth authorization. Pipedream manages the OAuth flow for these apps, ensuring you always have a fresh access token for requests.
14+
15+
**OAuth apps require you create your own OAuth client to [deploy to production](/connect/environments):**
16+
17+
<Callout type="info">
18+
To get started in [development mode](/connect/environments), you can skip these steps. To deploy your app to production, you'll need to [create an OAuth client](#using-a-custom-oauth-client) for the app you're integrating.
19+
</Callout>
20+
21+
## Using a custom OAuth client
22+
23+
1. Follow the steps [here](/connected-accounts/oauth-clients#configuring-custom-oauth-clients) to create an OAuth client in Pipedream.
24+
2. Open the **Apps** tab within your Pipedream project and select **Add app**.
25+
3. Select the app you're looking for, then select your OAuth client from the dropdown menu.
26+
4. When connecting an account either via the [frontend SDK](/connect/quickstart#use-the-pipedream-sdk-in-your-frontend), make sure to include the `oauth_app_id` in `pd.connectAccount()`.
27+
5. If using [Connect Link](/connect/quickstart#use-connect-link), make sure to include the `oauth_app_id` in the URL.
28+
29+
### Finding your OAuth app ID
30+
31+
[Create your OAuth client in Pipedream](https://pipedream.com/@/accounts/oauth-clients) then click the arrow to the left of the client name to expand the details.
32+
33+
<br />
34+
35+
<Image src="https://res.cloudinary.com/pipedreamin/image/upload/v1730241292/oauth-app-id_umhhqi.png" alt="Copy OAuth App ID" width={650} height={529} />

docs-v2/pages/connect/quickstart.mdx

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,10 @@ And here's the technical flow between your frontend, backend, and Pipedream's AP
2121

2222
<Steps>
2323

24-
### Add the apps you want to integrate
25-
26-
1. Open an existing Pipedream project or create a new one at [https://pipedream.com/projects](https://pipedream.com/projects).
27-
2. Click the **Connect** tab, then select **Apps**.
28-
3. From here, you can add any app to your project that you want to integrate with your application.
29-
30-
There are two types of apps in Pipedream:
31-
32-
1. **Key-based**: These apps require static credentials, like API keys. Pipedream stores these credentials securely and exposes them via API.
33-
2. **OAuth**: These apps require OAuth authorization. Pipedream manages the OAuth flow for these apps, ensuring you always have a fresh access token for requests.
34-
35-
**OAuth apps require you [create your own OAuth client](#creating-a-custom-oauth-client):**
36-
1. First, [create an OAuth client](/connected-accounts/oauth-clients#configuring-custom-oauth-clients) for the app you'd like to integrate.
37-
2. Now when selecting an OAuth app in the **Apps** tab, you'll be prompted to select the OAuth client you've created.
38-
3924
### Get your project keys
4025

41-
1. From within the the **Connect** tab in your project, select **Configuration**.
26+
1. Open an existing Pipedream project or create a new one at [https://pipedream.com/projects](https://pipedream.com/projects).
27+
2. From within the the **Connect** tab in your project, select **Configuration**.
4228
3. Find your project's **Public Key** and **Secret Key**.
4329

4430
You'll need these when configuring the SDK and making API requests.
@@ -47,15 +33,19 @@ You'll need these when configuring the SDK and making API requests.
4733

4834
<Image src="https://res.cloudinary.com/pipedreamin/image/upload/v1724773559/connect-keys_cb4ujt.png" alt="Project keys in the Connect tab" width={650} height={300} />
4935

50-
### Run the Pipedream demo app or configure your own
36+
### Run the Pipedream example app or configure your own
5137

52-
You'll need to do two things to integrate Pipedream Connect into your app:
38+
You'll need to do two things to add Pipedream Connect to your app:
5339

54-
1. [Connect to the Pipedream API from your server](#connect-to-the-pipedream-api-from-your-server-and-create-a-token). This lets you make secure calls to the Pipedream API to initiate the account connection flow and retrieve account credentials. If you're running a JavaScript framework like Node.js on the server, you can use the Pipedream SDK.
55-
2. [Add the Pipedream SDK to your frontend](#connect-your-account-from-the-frontend) or deliver a URL to your users to start the account connection flow.
40+
1. [Connect to the Pipedream API from your server](#connect-to-the-pipedream-api-from-your-server-and-create-a-token). This lets you make secure calls to the Pipedream API to initiate the account connection flow and retrieve account credentials. If you're running a JavaScript framework like Node.js on your server, you can use the Pipedream SDK.
41+
2. [Add the Pipedream SDK to your frontend](#connect-your-account-from-the-frontend) or redirect your users to [a Pipedream-hosted URL](/connect/connect-link) to start the account connection flow.
5642

5743
We'll walk through these steps below, using [an example Next.js app](https://github.com/PipedreamHQ/pipedream-connect-examples/tree/master/next-app/). To follow along, clone [the repo](https://github.com/PipedreamHQ/pipedream-connect-examples/) and follow the instructions in [the app's `README`](https://github.com/PipedreamHQ/pipedream-connect-examples/tree/master/next-app/). That will run the app on `localhost:3000`.
5844

45+
<Callout type="info">
46+
The Next.js app is just an example. You can build Connect apps in any framework, using any language. We've provided examples in Python, Ruby, and others below.
47+
</Callout>
48+
5949
First, copy the `.env.example` file to `.env.local`:
6050

6151
```bash
@@ -521,20 +511,28 @@ const { token, expires_at } = await serverConnectTokenCreate({
521511

522512
If you're using a different server / API framework, you'll need to make secure calls to that API to create a new token for your users. For example, you might validate a user's session, then call the Pipedream API to create a new token for that user.
523513

524-
### Connect your account
514+
<Callout type="info">
515+
Refer to the API docs for [all the parameters you can pass](/connect/api#create-a-new-token) in the `ConnectTokenCreate` call.
516+
</Callout>
517+
518+
### Connect a user's account
519+
520+
To connect a third-party account for a user, you have two options:
525521

526-
To actually connect an account, you have two options:
527522
1. [Use the Pipedream SDK](#use-the-pipedream-sdk-in-your-frontend) in your frontend
528-
2. [Use Connect Link](#use-connect-link) to deliver a hosted URL to your user
523+
2. [Use Connect Link](#use-connect-link) to deliver a hosted URL to your user (see above).
529524

530525
#### Use the Pipedream SDK in your frontend
526+
527+
Use this method when you want to handle the account connection flow yourself, in your app. For example, you might want to show a **Connect Slack** button in your app that triggers the account connection flow.
528+
531529
First, install the [Pipedream SDK](https://www.npmjs.com/package/@pipedream/sdk) in your frontend:
532530

533531
```bash
534532
npm i --save @pipedream/sdk
535533
```
536534

537-
When the user connects an account in your product, [fetch a token from your backend](#connect-to-the-pipedream-api-from-your-server-and-create-a-token) and call `connectAccount`. This opens a Pipedream iFrame that guides the user through the account connection.
535+
When the user connects an account in your product, [pass the token from your backend](#connect-to-the-pipedream-api-from-your-server-and-create-a-token) and call `connectAccount`. This opens a Pipedream iFrame that guides the user through the account connection.
538536

539537
In our example, `app/page.tsx` calls the `connectAccount` method from the Pipedream SDK when the user clicks the **Connect your account** button.
540538

@@ -549,7 +547,8 @@ export default function Home() {
549547
const pd = createClient()
550548
function connectAccount() {
551549
pd.connectAccount({
552-
app: process.env.NEXT_PUBLIC_PIPEDREAM_APP_SLUG, // From the Next.js example — adjust to pass your own app name slug
550+
app: appSlug, // Pass the app name slug of the app you want to integrate
551+
oauthAppId: appId, // For OAuth apps, pass the OAuth app ID; omit this param to use Pipedream's OAuth client or for key-based apps
553552
token: "YOUR_TOKEN", // The token you received from your server above
554553
onSuccess: ({ id: accountId }) => {
555554
console.log(`Account successfully connected: ${accountId}`)
@@ -559,7 +558,7 @@ export default function Home() {
559558

560559
return (
561560
<main>
562-
<button style={{ all: "revert" }} onClick={connectAccount}>Connect your account</button>
561+
<button onClick={connectAccount}>Connect your account</button>
563562
</main>
564563
)
565564
}
@@ -568,17 +567,20 @@ export default function Home() {
568567
Press that button to connect an account for the app you configured.
569568

570569
#### Use Connect Link
571-
- Avoid any frontend implementation
572-
- If you aren't able to execute JavaScript or open an iFrame in your frontend, you can use the `connect_link_url` that's returned from the `connectTokenCreate` method to deliver a URL to your users.
573-
- Before returning the URL to your user, you'll need to include the `app` on the URL. For example, see below.
574-
- Users can open this URL in a browser window to connect their account.
570+
571+
Use this option when you can't execute JavaScript or open an iFrame in your environment (e.g. mobile apps), or when you want to offload the account connection flow to Pipedream and avoid frontend work. You can also send these links via email or SMS.
572+
573+
The Connect Link opens a Pipedream-hosted page, guiding users through the account connection process. The URL is specific to the user and expires after 4 hours.
574+
575+
1. First, [generate a token](#generate-a-token) for your users.
576+
2. Extract the `connect_link_url` from the token response.
577+
3. Before returning the URL to your user, add an `app` parameter to the end of the query string:
575578

576579
```
577-
https://pipedream.com/_static/connect.html?token={token}&connectLink=true&app={appSlug}
580+
https://pipedream.com/_static/connect.html?token={token}&connectLink=true&app={appSlug}&oauthAppId={oauthAppId}
578581
```
579582

580-
**To test this code, check out this workflow:**
581-
[https://pipedream.com/new?h=tch_EvfbvQ](https://pipedream.com/new?h=tch_EvfbvQ)
583+
4. Redirect your users to this URL, or send it to them via email, SMS, and more.
582584

583585
### Retrieve the credentials from the backend
584586

@@ -971,6 +973,7 @@ response = client.get_user_accounts('USER_ID')
971973
972974
### Deploy your app to production
973975
974-
Now that you've successfully connected an account and retrieved the credentials, you're ready to deploy your app to production!
976+
- Now that you've successfully connected an account and retrieved the credentials, you're almost done!
977+
- Learn about [development environments](/connect/environments) and [using OAuth clients](/connect/oauth-clients) to deploy your app to production.
975978
976979
</Steps>

docs-v2/pages/connect/tokens.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Connect tokens
2+
3+
When you initiate account connection for your end users, you must either:
4+
5+
1. Generate a secure, short-lived token scoped to the end user, or
6+
2. Use the [Connect Link](/connect/connect-link) feature to generate a URL that guides the user through the account connection flow without any frontend work on your side.
7+
8+
Here, we'll show you how to generate tokens for your users and return that to your frontend, passing that to the account connection flow.
9+
10+
Use tokens when you want to handle the account connection flow yourself, in your app's UI. For example, you might want to show a **Connect Slack** button in your app that triggers the account connection flow for Slack, or launch the flow in a modal.
11+
12+
## Creating a token
13+
14+
See docs on [the `/tokens` endpoint](/connect/api/#create-a-new-token) to create new tokens.
15+
16+
## Webhooks
17+
18+
When you generate a token, you can specify a `webhook_uri` where Pipedream will deliver updates on the account connection flow. This is useful if you want to update your UI based on the status of the account connection flow, get a log of errors, and more.
19+
20+
[See the webhooks docs](/connect/webhooks) for more information.
21+
22+
## Tokens are scoped to end users and project environments
23+
24+
When you [create a new Connect token](/connect/api/#create-a-new-token), you pass an `external_user_id` and an optional `project_environment` parameter. By default, the enviromment is set to `production`.
25+
26+
Tokens are scoped to this user and environment. When the user successfully connects an account with that token, it will be saved for that `external_user_id` in the specified `project_environment`.

docs-v2/pages/connect/webhooks.mdx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Connect Webhooks
2+
3+
When you [generate a Connect token](/connect/quickstart/#generate-a-token), you can pass a `webhook_uri` parameter. Pipedream will send a POST request to this URL when the user completes the connection flow, or if an error occurs at any point. [See the API docs](/connect/api#create-a-new-token) for details.
4+
5+
## Webhook events
6+
7+
- `CONNECTION_SUCCESS` - Sent when the user successfully connects their account
8+
- `CONNECTION_ERROR` - Sent when an error occurs during the connection flow
9+
10+
## Webhook payload
11+
12+
### Successful connection
13+
14+
Please note that user credentials are not sent in the webhook request. To retrieve credentials, use the [Connect API to fetch the account](/connect/api#retrieve-account-details-by-id) using the `account.id` provided in the webhook payload.
15+
16+
```json
17+
{
18+
"event": "CONNECTION_SUCCESS",
19+
"connect_token": "abc123",
20+
"environment": "production",
21+
"connect_session_id": 123,
22+
"account": {
23+
"id": "apn_abc123",
24+
"name": "My Slack workspace",
25+
"external_id": "U123456",
26+
"healthy": true,
27+
"dead": false,
28+
"app": {
29+
"id": "app_abc123",
30+
"name_slug": "slack",
31+
"name": "Slack",
32+
"auth_type": "oauth",
33+
"description": "Slack is a channel-based messaging platform",
34+
"img_src": "https://assets.pipedream.net/icons/slack.svg",
35+
"custom_fields_json": [],
36+
"categories": "Communication",
37+
},
38+
"created_at": "2021-09-01T00:00:00Z",
39+
"updated_at": "2021-09-01T00:00:00Z",
40+
}
41+
}
42+
```
43+
44+
### Error
45+
46+
```json
47+
{
48+
"event": "CONNECTION_ERROR",
49+
"connect_token": "abc123",
50+
"environment": "production",
51+
"connect_session_id": 123,
52+
"error": "You've hit your limit on the number of external users you can connect."
53+
}
54+
```

0 commit comments

Comments
 (0)