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', | |
| }); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.api_key = "sk_example_123456789" | |
| end | |
| WorkOS.client.pipes.create_data_integration_token( | |
| slug: "github", | |
| user_id: "user_01EHZNVPK3SFK441A1RGBFSHRT" | |
| ) |
| from workos import WorkOSClient | |
| client = WorkOSClient(api_key="sk_example_123456789", client_id="client_123456789") | |
| client.pipes.create_data_integration_token( | |
| slug="github", user_id="user_01EHZNVPK3SFK441A1RGBFSHRT" | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v9" | |
| ) | |
| func main() { | |
| client := workos.NewClient("sk_example_123456789") | |
| _, err := client.Pipes().CreateDataIntegrationToken(context.Background(), "github", &workos.PipesCreateDataIntegrationTokenParams{ | |
| UserID: "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| }) | |
| if err != nil { | |
| panic(err) | |
| } | |
| } |
| <?php | |
| use WorkOS\WorkOS; | |
| $workos = new WorkOS( | |
| apiKey: "sk_example_123456789", | |
| clientId: "client_123456789", | |
| ); | |
| $workos | |
| ->pipes() | |
| ->createDataIntegrationToken( | |
| slug: "github", | |
| userId: "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| ); |
| import com.workos.WorkOS; | |
| import com.workos.pipes.PipesApi.CreateDataIntegrationTokenOptions; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| CreateDataIntegrationTokenOptions options = CreateDataIntegrationTokenOptions.builder() | |
| .userId("user_01EHZNVPK3SFK441A1RGBFSHRT") | |
| .build(); | |
| workos.pipes.createDataIntegrationToken("github", options); |
| using WorkOS; | |
| var client = new WorkOSClient(new WorkOSOptions { | |
| ApiKey = "sk_example_123456789", | |
| ClientId = "client_123456789", | |
| }); | |
| await client.Pipes.CreateDataIntegrationTokenAsync("github", new PipesCreateDataIntegrationTokenOptions { | |
| UserId = "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| }); |
| use workos::Client; | |
| use workos::pipes::CreateDataIntegrationTokenParams; | |
| #[tokio::main] | |
| async fn main() -> Result<(), workos::Error> { | |
| let client = Client::builder() | |
| .api_key("sk_example_123456789") | |
| .client_id("client_123456789") | |
| .build(); | |
| let _result = client | |
| .pipes() | |
| .create_data_integration_token( | |
| "github", | |
| CreateDataIntegrationTokenParams { | |
| user_id: "user_01EHZNVPK3SFK441A1RGBFSHRT".into(), | |
| ..Default::default() | |
| } | |
| ) | |
| .await?; | |
| Ok(()) | |
| } |
| { | |
| "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