Skip to content

Commit

Permalink
fix(api): GET /connection/:id new format (#3177)
Browse files Browse the repository at this point in the history
## Changes

Contributes to
https://linear.app/nango/issue/NAN-2363/session-token-polish
Fixes
https://linear.app/nango/issue/NAN-2396/get-connection-returns-user-and-org-info

- `GET /connection/:id` new format
Turns out we were also leaking iv but even documented it, don't think it
had any side-effects since we were returning the credentials unencrypted
anyway.

- Add missing OpenAPI schema

---------

Co-authored-by: Alan Johnson <alan@nango.dev>
Co-authored-by: nalanj <5594+nalanj@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 18, 2024
1 parent 7723a66 commit 007f69c
Show file tree
Hide file tree
Showing 24 changed files with 805 additions and 330 deletions.
36 changes: 1 addition & 35 deletions docs-v2/reference/api/connection/get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,9 @@ title: 'Get connection & credentials'
openapi: 'GET /connection/{connectionId}'
---

<ResponseExample>
```json Example Response
{
"id": 18393, // Nango internal connection id
"created_at": "2023-03-08T09:43:03.725Z", // Creation timestamp
"updated_at": "2023-03-08T09:43:03.725Z", // Last updated timestamp (e.g. last token refresh)
"provider_config_key": "github", // <INTEGRATION-ID>
"connection_id": "1", // <CONNECTION-ID>
"credentials": {
"type": "OAUTH2", // OAUTH2 or OAUTH1
"access_token": "gho_tsXLG73f....", // The current access token (refreshed if needed)
"refresh_token": "gho_fjofu84u9....", // Refresh token (Only returned if the REFRESH_TOKEN boolean parameter is set to true and the refresh token is available)
"expires_at": "2024-03-08T09:43:03.725Z", // Expiration date of access token (only if refresh token is present, otherwise missing)
"raw": { // Raw token response from the OAuth provider: Contents vary!
"access_token": "gho_tsXLG73f....",
"refresh_token": "gho_fjofu84u9....", // Refresh token (Only returned if the REFRESH_TOKEN boolean parameter is set to true and the refresh token is available)
"token_type": "bearer",
"scope": "public_repo,user"
}
},
"connection_config": { // Additional API Configuration, see OAuth guide
"subdomain": "myshop",
"realmId": "XXXXX",
"instance_id": "YYYYYYY"
},
"account_id": 0, // ID of your Nango account (Nango Cloud only)
"metadata": { // Custom metadata stored by you
"myProperty": "yes",
"filter": "closed=true"
}
}
```
</ResponseExample>

<Info>

The response content depends on the API authentication type (OAuth 2, OAuth 1, API key, Basic auth).
The response content depends on the API authentication type (e.g: OAuth 2, OAuth 1, API key, etc.).

If you do not want to deal with collecting & injecting credentials in requests for multiple authentication types, use the Proxy([step-by-step guide](/guides/proxy-requests-to-an-api)).

Expand Down
9 changes: 4 additions & 5 deletions docs-v2/reference/sdks/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ We recommend not caching tokens for longer than 5 minutes to ensure they are fre
"realmId": "XXXXX",
"instance_id": "YYYYYYY"
},
"account_id": 0,
"metadata": {
"myProperty": "yes",
"filter": "closed=true"
Expand Down Expand Up @@ -939,7 +938,7 @@ await nango.startSync('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNEC
The name of the syncs that should be triggered.
</ResponseField>
<ResponseField name="connectionId" type="string">
The connection ID. If ommitted, the sync will trigger for all relevant connections.
The connection ID. If omitted, the sync will trigger for all relevant connections.
</ResponseField>
</Expandable>

Expand All @@ -965,7 +964,7 @@ await nango.startSync('<INTEGRATION-ID>', ['SYNC_NAME1', 'SYNC_NAME2'], '<CONNEC
The name of the syncs that should be paused.
</ResponseField>
<ResponseField name="connectionId" type="string">
The connection ID. If ommitted, the sync will pause for all relevant connections.
The connection ID. If omitted, the sync will pause for all relevant connections.
</ResponseField>
</Expandable>

Expand Down Expand Up @@ -1108,7 +1107,7 @@ await nango.triggerAction('<INTEGRATION-ID>', '<CONNECTION_ID>', '<ACTION-NAME>'
<ResponseField name="actionName" type="string" required>
The name of the action to trigger.
</ResponseField>
<ResponseField name="input" type="unkown" required>
<ResponseField name="input" type="unknown" required>
The necessary input for your action's `runAction` function.
</ResponseField>
</Expandable>
Expand Down Expand Up @@ -1171,7 +1170,7 @@ await nango.delete(config); // DELETE request
Array of additional status codes to retry a request in addition to the 5xx, 429, ECONNRESET, ETIMEDOUT, and ECONNABORTED
</ResponseField>
<ResponseField name="baseUrlOverride" type="string">
The API base URL. Can be ommitted if the base URL is configured for this API in the [providers.yaml](https://nango.dev/providers.yaml).
The API base URL. Can be omitted if the base URL is configured for this API in the [providers.yaml](https://nango.dev/providers.yaml).
</ResponseField>
<ResponseField name="decompress" type="boolean">
Override the decompress option when making requests. Optional, defaults to false
Expand Down
Loading

0 comments on commit 007f69c

Please sign in to comment.