Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs-v2/pages/connect/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"quickstart": {
"title": "Quickstart"
},
"workflows": {
"title": "Running workflows"
},
"api": {
"title": "API & SDK Reference"
},
Expand All @@ -26,6 +29,9 @@
"connect-link": {
"title": "Connect Link"
},
"troubleshooting": {
"title": "Troubleshooting"
},
"migrating-from-project-keys-to-oauth": {
"display": "hidden"
}
Expand Down
197 changes: 85 additions & 112 deletions docs-v2/pages/connect/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import { createBackendClient } from "@pipedream/sdk";
// These secrets should be saved securely and passed to your environment
const pd = createBackendClient({
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
}
});

Expand Down Expand Up @@ -123,62 +123,7 @@ If you need higher rate limits, please [reach out](https://pipedream.com/support

### Invoke workflows

You can use the SDK to invoke workflows on behalf of any end user. **Write one workflow, run it for all of your users**.

<Tabs items={['TypeScript', 'Node.js']}>
<Tabs.Tab>
```typescript
import { createBackendClient, HTTPAuthType } from "@pipedream/sdk";

// These secrets should be saved securely and passed to your environment
const pd = createBackendClient({
credentials: {
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
},
});

await pd.invokeWorkflowForExternalUser(
"enabc123", // pass the endpoint ID or full URL here
"external_user_id" // The end user's ID in your system
{
method: "POST",
body: {
key: "value",
}
},
HTTPAuthType.OAuth // Will automatically send the Authorization header with a fresh token
)
```
</Tabs.Tab>
<Tabs.Tab>
```javascript
import { createBackendClient } from "@pipedream/sdk";

// These secrets should be saved securely and passed to your environment
const pd = createBackendClient({
credentials: {
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
},
});

await pd.invokeWorkflowForExternalUser(
"enabc123", // pass the endpoint ID or full URL here
"external_user_id" // The end user's ID in your system
{
method: "POST",
body: {
key: "value",
}
},
"oauth" // Will automatically send the Authorization header with a fresh token
)
```
</Tabs.Tab>
</Tabs>

See the [workflow invocation docs](/workflows/triggers#oauth) for more details.
You can use the SDK to [invoke workflows on behalf of any end user](/connect/workflows). **Write one workflow, run it for all of your users**.

### Tokens

Expand Down Expand Up @@ -206,6 +151,12 @@ The ID of your end user. Use whatever ID uniquely identifies the user in your sy

---

`environment` **string**

Specify the environment (`production` or `development`) to use for the account connection flow.

---

`success_redirect_uri` **string** (_optional_)

When using [Connect Link](/connect/connect-link), you can optionally redirect your end user to the `success_redirect_uri` on successful completion of the auth flow.
Expand All @@ -222,12 +173,6 @@ When using [Connect Link](/connect/connect-link), you can optionally redirect yo

Pipedream will send events on successful auth, or any errors, to this URL via webhook. [See the webhooks docs](/connect/webhooks) for more information.

---

`project_environment` **string** (_optional_)

Specify the environment (`production` or `development`) to use for the account connection flow. Defaults to `production`.

##### Examples

To create a short-lived token via TypeScript / JavaScript SDK, you'll need to create a Pipedream API client and call the `createConnectToken` method. In our example app, this code is in `app/server.ts`.
Expand All @@ -245,15 +190,17 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const { token, expires_at } = await pd.createConnectToken({
project_id: "your-project-id",
external_user_id: "your-external-user-id" // The end user's ID in your system
project_id: "{your_project_id}",
external_user_id: "{your_external_user_id}" // The end user's ID in your system
});
```
</Tabs.Tab>
Expand All @@ -262,15 +209,17 @@ const { token, expires_at } = await pd.createConnectToken({
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const { token, expires_at } = await pd.createConnectToken({
project_id: "your-project-id",
external_user_id: "your-external-user-id", // The end user's ID in your system
project_id: "{your_project_id}",
external_user_id: "{your_external_user_id}", // The end user's ID in your system
});
```
</Tabs.Tab>
Expand All @@ -291,7 +240,7 @@ curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "your-external-user-id"
"external_user_id": "{your_external_user_id}"
}'
```
</Tabs.Tab>
Expand Down Expand Up @@ -349,10 +298,12 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const accounts = await pd.getAccounts({
Expand All @@ -368,10 +319,12 @@ const accounts = await pd.getAccounts({
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const accounts = await pd.getAccounts({
Expand Down Expand Up @@ -513,10 +466,12 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const account = await pd.getAccount(accountId, {
Expand All @@ -532,10 +487,12 @@ const account = await pd.getAccount(accountId, {
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const accountId = "{account_id}"; // Replace with your account ID
Expand Down Expand Up @@ -653,10 +610,12 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

await pd.deleteAccount(accountId);
Expand All @@ -669,10 +628,12 @@ await pd.deleteAccount(accountId);
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

await pd.deleteAccount(accountId);
Expand Down Expand Up @@ -733,10 +694,12 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

await pd.deleteAccountsByApp(appId);
Expand All @@ -749,10 +712,12 @@ await pd.deleteAccountsByApp(appId);
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

await pd.deleteAccount(accountId);
Expand Down Expand Up @@ -813,10 +778,12 @@ import {
} from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

await pd.deleteExternalUser(externalId);
Expand All @@ -829,10 +796,12 @@ console.log("All accounts associated with the external ID have been deleted.");
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const externalId = "{external_user_id}"; // Replace with your external user ID
Expand Down Expand Up @@ -889,14 +858,16 @@ GET /{project_id}/info
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const info = await pd.getProjectInfo({
project_id: "your-project-id",
project_id: "{your_project_id}",
});
```
</Tabs.Tab>
Expand All @@ -905,14 +876,16 @@ const info = await pd.getProjectInfo({
import { createBackendClient } from "@pipedream/sdk";

const pd = createBackendClient({
environment: "development", // change to production if running for a test production account, or in production
credentials: {
clientId: "your-oauth-client-id",
clientSecret: "your-oauth-client-secret",
}
clientId: "{oauth_client_id}",
clientSecret: "{oauth_client_secret}",
},
projectId: "{your_project_id}"
});

const info = await pd.getProjectInfo({
project_id: "your-project-id",
project_id: "{your_project_id}",
});
```
</Tabs.Tab>
Expand Down
Loading