Widgets are React components that provide complete functionality for common enterprise app workflows.
Generate a widget token scoped to an organization and user with the specified scopes.
curl --request POST \ --url "https://api.workos.com/widgets/token" \ --header "Authorization: Bearer sk_example_123456789" \ --header "Content-Type: application/json" \ -d @- <<'BODY' { "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "scopes": [ "widgets:users-table:manage" ] } BODY
{ "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InNlc3Npb24..." }
| curl --request POST \ | |
| --url "https://api.workos.com/widgets/token" \ | |
| --header "Authorization: Bearer sk_example_123456789" \ | |
| --header "Content-Type: application/json" \ | |
| -d @- <<'BODY' | |
| { | |
| "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", | |
| "scopes": [ | |
| "widgets:users-table:manage" | |
| ] | |
| } | |
| BODY |
| import { WorkOS } from '@workos-inc/node'; | |
| const workos = new WorkOS('sk_example_123456789'); | |
| const { token } = await workos.widgets.getToken({ | |
| organizationId: 'org_01EHZNVPK3SFK441A1RGBFSHRT', | |
| userId: 'user_01EHZNVPK3SFK441A1RGBFSHRT', | |
| scopes: ['widgets:users-table:manage'], | |
| }); |
| require "workos" | |
| WorkOS.configure do |config| | |
| config.key = "sk_example_123456789" | |
| end | |
| token = WorkOS::Widgets.get_token( | |
| organization_id: "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| user_id: "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| scopes: ["widgets:users-table:manage"] | |
| ) |
| from workos import WorkOSClient | |
| workos_client = WorkOSClient( | |
| api_key="sk_example_123456789", client_id="client_123456789" | |
| ) | |
| token_response = workos_client.widgets.get_token( | |
| organization_id="org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| user_id="user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| scopes=["widgets:users-table:manage"], | |
| ) |
| package main | |
| import ( | |
| "context" | |
| "github.com/workos/workos-go/v4/pkg/widgets" | |
| ) | |
| func main() { | |
| widgets.SetAPIKey("sk_example_123456789") | |
| token, err := widgets.GetToken( | |
| context.Background(), | |
| widgets.GetTokenOpts{ | |
| OrganizationID: "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| UserID: "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| Scopes: []widgets.WidgetScope{widgets.UsersTableManage}, | |
| }, | |
| ) | |
| } |
| <?php | |
| use WorkOS\Resource\WidgetScope; | |
| WorkOS\WorkOS::setApiKey("sk_example_123456789"); | |
| $widgets = new WorkOS\Widgets(); | |
| $token_response = $widgets->getToken( | |
| organization_id: "org_01EHZNVPK3SFK441A1RGBFSHRT", | |
| user_id: "user_01EHZNVPK3SFK441A1RGBFSHRT", | |
| scopes: [WidgetScope::UsersTableManage] | |
| ); |
| import com.workos.WorkOS; | |
| import com.workos.widgets.WidgetsApi.GetTokenOptions; | |
| import com.workos.widgets.models.WidgetScope; | |
| import com.workos.widgets.models.WidgetTokenResponse; | |
| WorkOS workos = new WorkOS("sk_example_123456789"); | |
| String organizationId = "org_01EHZNVPK3SFK441A1RGBFSHRT"; | |
| String userId = "user_01EHZNVPK3SFK441A1RGBFSHRT"; | |
| GetTokenOptions options = GetTokenOptions.builder() | |
| .organizationID(organizationId) | |
| .userID(userId) | |
| .scopes(Arrays.asList(WidgetScope.WidgetsUsersTableManage)) | |
| .build(); | |
| Link response = workos.widgets.getToken(options); | |
| String token = response.token; |
| { | |
| "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6InNlc3Npb24..." | |
| } |
POST/widgets /tokenReturns