This endpoint is called by WorkOS Connect Applications to get access tokens, ID tokens, and refresh tokens, depending on the grant_type provided when requested.
This endpoint is authenticated by providing the WorkOS Application’s client ID and client secret in the body of the request.
There are four grant types available:
Each is described in greater detail below.
Used by WorkOS Connect OAuth Applications to exchange an authorization code for access tokens, ID tokens, and refresh tokens.
curl -X POST https://<subdomain>.authkit.app/oauth2/token \ -d "client_id=client_01JP8BD0CZ401TDF9X54NT5ZEK" \ -d "client_secret=1eaaf7a47948398d89e2b07dce912b6a9c0282aa20e88c026fcb42fd6b06b73e" \ -d "grant_type=authorization_code" \ -d "code=01JMGA70GA2W47M7Z53JG355GW" \ -d "redirect_uri=https://app.example.com/callback"
POST/oauth2 /tokenParameters Returns objectThe access token for WorkOS Connect OAuth Applications contains the following claims.
{ "iss": "https://<subdomain>.authkit.app", "aud": "client_123456789", "sub": "user_01JQ0E27VT3MH79RY0FVA4QBP9", "org_id": "org_01HRDMC6CM357W30QMHMQ96Q0S", "sid": "app_consent_01JQ0E27WE4K1RCMH7Q094M1GJ", "jti": "01JQ0E27ZXE4XNHVP870S6PWYN", "exp": 1742698034, "iat": 1742697734 }
Access token JWTThe ID token, when requested with the openid scope, contains information about the user’s identity, like name and email address.
{ "iss": "https://<subdomain>.authkit.app", "aud": "client_01JP8BD0CZ401TDF9X54NT5ZEK", "sub": "user_01JQ0E27VT3MH79RY0FVA4QBP9", "name": "Leroy Jenkins", "given_name": "Leroy", "family_name": "Jenkins", "email": "leroy.jenkins@example.com", "email_verified": true, "nonce": "f39a8e47d2c9b6fa", "exp": 1742702581, "iat": 1742698981 }
ID token JWTUsed by WorkOS Connect OAuth Applications to exchange a refresh token for new access tokens and/or ID tokens. The refresh token is provided when the initial oauth2/authorize request is made with the offline_access scope.
The access token and ID tokens issued here are the same as those issued for the initial authorization_code grant.
curl -X POST https://<subdomain>.authkit.app/oauth2/token \ -d "client_id=client_01JP8BD0CZ401TDF9X54NT5ZEK" \ -d "client_secret=1eaaf7a47948398d89e2b07dce912b6a9c0282aa20e88c026fcb42fd6b06b73e" \ -d "grant_type=refresh_token" \ -d "refresh_token=01JMGA70GA2W47M7Z53JG355GW" \ -d "scope=openid profile email"
POST/oauth2 /tokenParameters Returns objectUsed by WorkOS Connect M2M Applications to exchange the app’s credentials for access tokens.
curl -X POST https://<subdomain>.authkit.app/oauth2/token \ -d "client_id=client_01JP8BD0CZ401TDF9X54NT5ZEK" \ -d "client_secret=1eaaf7a47948398d89e2b07dce912b6a9c0282aa20e88c026fcb42fd6b06b73e" \ -d "grant_type=client_credentials"
POST/oauth2 /tokenParameters Returns objectThe access token for WorkOS Connect M2M Applications contains the following claims.
{ "iss": "https://<subdomain>.authkit.app", "aud": "client_01K25SZKHKNZZYSP7E5E3N2T0M", "sub": "client_01HK20JT00434A411X45ZNPTBA", "org_id": "org_01HZ99J6C0H3JBP78CYQM7J0FE", "sid": "app_consent_01JQ0E27WE4K1RCMH7Q094M1GJ", "jti": "01JQ0E27ZXE4XNHVP870S6PWYN", "exp": 1742698034, "iat": 1742697734 }
Access token JWT