An access token allows you to make API calls to a connected third-party service on behalf of a user. WorkOS handles token refresh automatically, so you always receive a valid, non-expired token.
Fetches a valid OAuth access token for a user’s connected account. WorkOS automatically handles token refresh, ensuring you always receive a valid, non-expired token.
curl --request POST \ --url "https://api.workos.com/data-integrations/github/token" \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<'BODY' { "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT" } BODY
{ "active": true, "access_token": { "object": "access_token", "access_token": "gho_16C7e42F292c6912E7710c838347Ae178B4a", "expires_at": "2025-12-31T23:59:59.000Z", "scopes": [ "repo", "user:email" ], "missing_scopes": [] } }
| curl --request POST \ | |
| --url "https://api.workos.com/data-integrations/github/token" \ | |
| --header "Authorization: Bearer sk_example_123456789" \ | |
| --header "Content-Type: application/json" \ | |
| -d @- <<'BODY' | |
| { | |
| "user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT" | |
| } | |
| BODY |
| import { WorkOS } from '@workos-inc/node'; | |
| const workos = new WorkOS('sk_example_123456789'); | |
| const token = await workos.pipes.getAccessToken({ | |
| userId: 'user_01EHZNVPK3SFK441A1RGBFSHRT', | |
| organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', | |
| provider: 'github', | |
| }); |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v6/pkg/pipes" | |
| ) | |
| func main() { | |
| pipes.SetAPIKey( | |
| "sk_example_123456789", | |
| ) | |
| token, err := pipes.GetAccessToken( | |
| context.Background(), | |
| pipes.GetAccessTokenOpts{ | |
| Provider: "github", | |
| UserID: "user_01KG62RSFMHXBA93B43BHVKTK9", | |
| OrganizationID: "org_01KG62RSFM0N7NCGB31CVWDH2A", | |
| }, | |
| ) | |
| } |
| { | |
| "active": true, | |
| "access_token": { | |
| "object": "access_token", | |
| "access_token": "gho_16C7e42F292c6912E7710c838347Ae178B4a", | |
| "expires_at": "2025-12-31T23:59:59.000Z", | |
| "scopes": [ | |
| "repo", | |
| "user:email" | |
| ], | |
| "missing_scopes": [] | |
| } | |
| } |
POST/data-integrations /:slug /tokenParameters Returns