Prerequisites
- A WorkOS account with User Management enabled
- Admin access to your WorkOS dashboard
- Access to the Char dashboard
Quick Links
WorkOS Dashboard
Sign in to your WorkOS Dashboard
WorkOS Docs
User Management documentation
AuthKit Documentation
AuthKit SDK reference
Sessions & JWTs
Session and JWT documentation
SDK References
@workos-inc/authkit-react
AuthKit React SDK
@workos-inc/authkit-nextjs
AuthKit Next.js SDK
@workos-inc/authkit-js
AuthKit vanilla JavaScript SDK
@workos-inc/node
WorkOS Node.js SDK
Configuration Steps
Create or Select Your WorkOS Environment
- Sign in to the WorkOS Dashboard
- Select your environment (Production or Staging)
- Navigate to User Management in the sidebar
WorkOS provides separate Production and Staging environments. Use Staging for development and testing.
Note Your Client ID
From the WorkOS Dashboard:
- Navigate to API Keys in the sidebar
- Copy your Client ID (starts with
client_)
See WorkOS AuthKit documentation for screenshots of the dashboard setup process.
Configure the Audience Claim (Critical)
WorkOS does not include the
aud claim by default. You must explicitly configure it:- In the WorkOS Dashboard, navigate to Authentication → Sessions
- Under Session Configuration, find JWT Claims
- Click Add Custom Claim
- Configure the audience claim:
| Setting | Value |
|---|---|
| Claim Name | aud |
| Claim Value | Your Client ID (e.g., client_01234567890ABCDEF) |
- Click Save
| Setting | Value |
|---|---|
| Claim Name | aud |
| Claim Value | char-ai-agent (or your preferred identifier) |
Configure Redirect URIs
In the WorkOS Dashboard:
- Navigate to Authentication → Redirects
- Add your application’s callback URLs:
https://yourapp.com/callback(production)http://localhost:3000/callback(development)
- Add your logout redirect URLs if using sign-out functionality
Configure Char
In the Char Dashboard:
- Navigate to Settings → Integration
- Under SSO Configuration, select Custom OIDC as the provider
- Enter your configuration:
| Field | Value |
|---|---|
| Client ID | Your WorkOS Client ID or custom aud value |
| Issuer URL | https://api.workos.com/user_management/{your-client-id} |
- Click Test Connection to verify
- Click Save Changes
Configuration Reference
| Char Field | WorkOS Value | Example |
|---|---|---|
| Provider Type | Custom OIDC | custom_oidc |
| Client ID | Your configured aud claim value | client_01234567890ABCDEF |
| Issuer URL | WorkOS User Management issuer | https://api.workos.com/user_management/client_01234567890ABCDEF |
WorkOS uses the Custom OIDC provider type in Char because it has a unique issuer URL format that includes your client ID.
Token Requirements
Char validates WorkOS tokens with these requirements:| Claim | Requirement |
|---|---|
iss | Must match https://api.workos.com/user_management/{client-id} |
aud | Must include your configured audience value |
sub | Required - used as the user identifier (WorkOS user ID) |
exp | Must not be expired |
Standard WorkOS Token Claims
WorkOS tokens include these claims by default:| Claim | Description |
|---|---|
sub | WorkOS user ID (e.g., user_01234567890ABCDEF) |
sid | Session ID |
org_id | Organization ID (if user is in an organization) |
role | User’s role in the organization |
email | User’s email address |
Example: Obtaining and Passing the Token
- AuthKit (React)
- AuthKit (JavaScript)
- Next.js (AuthKit)
WorkOS Organizations
If you’re using WorkOS Organizations for B2B authentication:- Users can belong to multiple organizations
- The
org_idclaim indicates the currently selected organization - Char uses the
subclaim (user ID) for end-user identification
Troubleshooting
INVALID_AUDIENCE error
INVALID_AUDIENCE error
The most common issue with WorkOS. The token doesn’t include or doesn’t match the configured audience:
-
Verify
audclaim is configured in WorkOS:- Go to WorkOS Dashboard → Authentication → Sessions
- Check that you’ve added a custom
audclaim - Verify the value matches what you configured in Char
-
Verify the claim value matches exactly:
- If you used your Client ID as the audience, ensure it matches exactly
- Check for any typos or whitespace
-
Regenerate the token:
- After adding the
audclaim, users need to sign in again - Existing tokens won’t have the new claim
- After adding the
INVALID_ISSUER error
INVALID_ISSUER error
The token issuer doesn’t match the expected format:
- Verify your Issuer URL in Char follows the format:
https://api.workos.com/user_management/{client-id} - Ensure you’re using the correct Client ID (starts with
client_) - Check that you haven’t confused Production and Staging environments
JWKS_FETCH_FAILED error
JWKS_FETCH_FAILED error
Char couldn’t reach WorkOS’s JWKS endpoint:
- The JWKS URL is
https://api.workos.com/sso/jwks/{client-id} - Verify your Client ID is correct
- Use Test Connection in the dashboard to verify connectivity
Token missing email claim
Token missing email claim
WorkOS access tokens may not always include the email:
- This is expected behavior in some configurations
- Char uses the
subclaim (user ID) as the primary identifier - Email is optional for Char authentication
Development vs Production tokens
Development vs Production tokens
WorkOS AuthKit development mode uses different token formats:
- Development tokens may have different issuer URLs
- For testing with Char, use your Production or Staging environment
- Ensure you’ve configured the
audclaim in the environment you’re testing
WorkOS SSO Connections
If you’re using WorkOS SSO (SAML/OIDC connections to enterprise IDPs):- Users authenticate through their enterprise IDP (Okta, Azure AD, etc.)
- WorkOS issues its own JWT token
- Pass the WorkOS token to Char (not the upstream IDP token)
When using WorkOS SSO, the user’s identity comes from their enterprise IDP, but the token validation is performed against WorkOS’s keys.
Security Best Practices
Additional recommendations:- Use separate environments for production and development
- Configure appropriate session timeouts in WorkOS dashboard
- Enable MFA for sensitive applications
- Review authentication logs in WorkOS dashboard for anomalies
- Use WorkOS Organizations for B2B scenarios with proper role-based access
- Rotate Client Secrets periodically (note: secrets aren’t used for token validation, only for server-side API calls)

