Skip to content

Commit 94824d6

Browse files
Danny/connect api docs patch2 (#14929)
* updating code examples * Update pnpm-lock.yaml * Update api.mdx
1 parent ba845b1 commit 94824d6

File tree

2 files changed

+117
-16
lines changed

2 files changed

+117
-16
lines changed

docs-v2/pages/connect/api.mdx

Lines changed: 113 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ The ID of the [OAuth app](/connect/quickstart#create-a-pipedream-oauth-client) y
305305

306306
[The external user ID](/connect/api/#external-users) in your system that you want to retrieve accounts for.
307307

308+
---
309+
310+
`include_credentials` **boolean** (_optional_)
311+
312+
Pass `include_credentials=true` as a query-string parameter to include the account credentials in the response.
313+
314+
<Callout type="warning">
315+
Never return user credentials to the client
316+
</Callout>
317+
318+
<Callout type="info">
319+
To retrieve the credentials for any account in `production` for OAuth apps (Slack, Google Sheets, etc), the connected account must be using [your own OAuth client](/connect/oauth-clients#using-a-custom-oauth-client). You can only retrieve end user credentials for accounts that are using Pipedream's OAuth clients in `development`. [Learn more here](/connect/oauth-clients#using-pipedream-oauth).
320+
</Callout>
308321

309322
##### Examples
310323

@@ -324,9 +337,14 @@ const pd = createBackendClient({
324337
projectId: "{your_project_id}"
325338
});
326339

327-
const accounts = await pd.getAccounts();
340+
const accounts = await pd.getAccounts({
341+
app: "github", // optional, filter by app
342+
external_user_id: "user-abc-123", // optional, filter by external user ID
343+
include_credentials: true, // optional, set to true to include credentials
344+
});
328345

329-
// Parse and return the data you need
346+
// Parse and return the data you need. These may contain credentials,
347+
// which you should never return to the client
330348
```
331349
</Tabs.Tab>
332350
<Tabs.Tab>
@@ -342,9 +360,14 @@ const pd = createBackendClient({
342360
projectId: "{your_project_id}"
343361
});
344362

345-
const accounts = await pd.getAccounts();
363+
const accounts = await pd.getAccounts({
364+
app: "github", // optional, filter by app
365+
external_user_id: "user-abc-123", // optional, filter by external user ID
366+
include_credentials: true, // optional, set to true to include credentials
367+
});
346368

347-
// Parse and return the data you need
369+
// Parse and return the data you need. These may contain credentials,
370+
// which you should never return to the client
348371
```
349372
</Tabs.Tab>
350373
<Tabs.Tab>
@@ -360,16 +383,31 @@ curl -X POST https://api.pipedream.com/v1/oauth/token \
360383

361384
# The response will include an access_token. Use it in the Authorization header below.
362385

363-
curl -X GET "https://api.pipedream.com/v1/connect/{project_id}/accounts" \
364-
-H "Authorization: Bearer {access_token}"
386+
curl -X GET \
387+
-G \
388+
"https://api.pipedream.com/v1/connect/{project_id}/accounts" \
389+
-H "Authorization: Bearer {access_token}" \
390+
-d "app=github" \ # optional, filter by app
391+
-d "external_user_id=user-abc-123" \ # optional, filter by external user ID
392+
-d "include_credentials=true" # optional, include credentials
393+
394+
395+
# Parse and return the data you need. These may contain credentials,
396+
# which you should never return to the client
365397
```
366398
</Tabs.Tab>
367399
</Tabs>
368400

369-
##### Example response
401+
##### Example response (without credentials)
370402

371403
```json
372404
{
405+
"page_info": {
406+
"total_count": 5,
407+
"count": 5,
408+
"start_cursor": "YXBuX0JtaEJKSm0",
409+
"end_cursor": "YXBuX1YxaE1lTE0",
410+
},
373411
"data": {
374412
"accounts": [
375413
{
@@ -442,6 +480,53 @@ curl -X GET "https://api.pipedream.com/v1/connect/{project_id}/accounts" \
442480
}
443481
```
444482

483+
##### Example response (with credentials)
484+
485+
```json
486+
{
487+
"page_info": {
488+
"total_count": 1,
489+
"count": 1,
490+
"start_cursor": "YXBuX0JtaEJKSm0",
491+
"end_cursor": "YXBuX1YxaE1lTE0",
492+
},
493+
"data": {
494+
"accounts":[
495+
{
496+
"id": "apn_MGhvgnX",
497+
"name": "gcostanza",
498+
"external_id": "user-abc-123",
499+
"healthy": true,
500+
"dead": null,
501+
"app": {
502+
"id": "oa_aPXiQd",
503+
"name_slug": "github",
504+
"name": "GitHub",
505+
"auth_type": "oauth",
506+
"description": "Where the world builds software. Millions of developers and companies build, ship, and maintain their software on GitHub—the largest and most advanced development platform in the world.",
507+
"img_src": "https://assets.pipedream.net/s.v0/app_OrZhaO/logo/orig",
508+
"custom_fields_json": "[]",
509+
"categories": [
510+
"Developer Tools"
511+
]
512+
},
513+
"created_at": "2024-12-03T04:26:38.000Z",
514+
"updated_at": "2024-12-11T17:59:28.000Z",
515+
"credentials": {
516+
"oauth_client_id": "xyz789...",
517+
"oauth_access_token": "xxx_abc123...",
518+
"oauth_uid": "123456789"
519+
},
520+
"expires_at": null,
521+
"error": null,
522+
"last_refreshed_at": "2024-12-11T17:59:28.000Z",
523+
"next_refresh_at": "2024-12-11T18:56:28.000Z"
524+
}
525+
]
526+
}
527+
}
528+
```
529+
445530
#### Retrieve account details by ID
446531

447532
Retrieve the account details for a specific account based on the account ID
@@ -468,6 +553,10 @@ The ID of the account you want to retrieve
468553

469554
Pass `include_credentials=true` as a query-string parameter to include the account credentials in the response.
470555

556+
<Callout type="warning">
557+
Never return user credentials to the client
558+
</Callout>
559+
471560
<Callout type="info">
472561
To retrieve the credentials for any account in `production` for OAuth apps (Slack, Google Sheets, etc), the connected account must be using [your own OAuth client](/connect/oauth-clients#using-a-custom-oauth-client). You can only retrieve end user credentials for accounts that are using Pipedream's OAuth clients in `development`. [Learn more here](/connect/oauth-clients#using-pipedream-oauth).
473562
</Callout>
@@ -491,7 +580,9 @@ const pd = createBackendClient({
491580
});
492581

493582
const account = await pd.getAccountById(accountId, {
494-
include_credentials: true, // set to true to include credentials
583+
app: "github", // optional, filter by app
584+
external_user_id: "user-abc-123", // optional, filter by external user ID
585+
include_credentials: true, // optional, set to true to include credentials
495586
});
496587

497588
// Parse and return the data you need. These may contain credentials,
@@ -514,7 +605,9 @@ const pd = createBackendClient({
514605
const accountId = "{account_id}"; // Replace with your account ID
515606

516607
const account = await pd.getAccountById(accountId, {
517-
include_credentials: true, // set to true to include credentials
608+
app: "github", // optional, filter by app
609+
external_user_id: "user-abc-123", // optional, filter by external user ID
610+
include_credentials: true, // optional, set to true to include credentials
518611
});
519612

520613
// Parse and return the data you need. These may contain credentials,
@@ -534,8 +627,16 @@ curl -X POST https://api.pipedream.com/v1/oauth/token \
534627

535628
# The response will include an access_token. Use it in the Authorization header below.
536629

537-
curl -X GET "https://api.pipedream.com/v1/connect/{project_id}/accounts/{account_id}?include_credentials=true" \
538-
-H "Authorization: Bearer {access_token}"
630+
curl -X GET \
631+
-G \
632+
"https://api.pipedream.com/v1/connect/{project_id}/accounts/{account_id}" \
633+
-H "Authorization: Bearer {access_token}" \
634+
-d "app=github" \ # optional, filter by app
635+
-d "external_user_id=user-abc-123" \ # optional, filter by external user ID
636+
-d "include_credentials=true" # optional, include credentials
637+
638+
# Parse and return the data you need. These may contain credentials,
639+
# which you should never return to the client
539640
```
540641
</Tabs.Tab>
541642
</Tabs>
@@ -590,7 +691,7 @@ curl -X GET "https://api.pipedream.com/v1/connect/{project_id}/accounts/{account
590691
},
591692
"expires_at": "2024-08-01T05:04:03.000Z",
592693
"project_id": 279440,
593-
"user_id": "danny",
694+
"user_id": "gcostanza",
594695
"error": null,
595696
"last_refreshed_at": null,
596697
"next_refresh_at": "2024-08-01T04:17:33.000Z"

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)