Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions docs-v2/pages/connect/_meta.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
{
"index": {
"title": "Overview"

Check failure on line 3 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"use-cases": {
"title": "Use cases"

Check failure on line 6 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"quickstart": {
"title": "Quickstart"

Check failure on line 9 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"workflows": {
"title": "Running workflows"

Check failure on line 12 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"api": {
"title": "API & SDK Reference"

Check failure on line 15 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"tokens": {
"title": "Connect tokens"

Check failure on line 18 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"environments": {
"title": "Environments"

Check failure on line 21 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"oauth-clients": {
"title": "OAuth Clients"

Check failure on line 24 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"webhooks": {
"title": "Webhooks"

Check failure on line 27 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"connect-link": {
"title": "Connect Link"

Check failure on line 30 in docs-v2/pages/connect/_meta.json

View workflow job for this annotation

GitHub Actions / Lint Code Base

Missing trailing comma
},
"migrating-from-project-keys-to-oauth": {
"display": "hidden"
Expand Down
185 changes: 79 additions & 106 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 @@ -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
16 changes: 10 additions & 6 deletions docs-v2/pages/connect/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,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}"
});

async function getUserAccounts(external_user_id: string, include_credentials: boolean = false) {
Expand All @@ -198,10 +200,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}"
});

async function getUserAccounts(external_user_id, include_credentials = false) {
Expand Down
Loading
Loading