Skip to content
Dashboard
Theme
Theme

Exchange an authorization code

POST /v1/sso/token: Exchange an authorization code.

View Markdown

POST /v1/sso/token

Single-use code (60 s) bound to the environment, client_id and redirect_uri; PKCE S256 only. A second exchange of a code fails and revokes the access token issued from the first. Errors: invalid_grant (also when the issuing cell cannot confirm single use), pkce_verification_failed. Served by the broker on the auth host only; the api host answers not_implemented.

Scope
sso:exchange
Auth
Secret key (sk_…)
Since
1.0
  • OhAuthCat-Version string

    Minor version; defaults to the environment’s pin.

  • Idempotency-Key string

    Honoured for 24 h; a replay returns the original response.

    min length 1 · max length 255

  • grant_type string Required

    one of authorization_code

  • code string Required

    min length 1

  • code_verifier string Required

    min length 43 · max length 128

  • client_id string Required

    The publishable key (pk_…) the code was requested with on /sso/authorize.

    min length 1

  • redirect_uri string (uri) Required

Errors share one shape; see the error code catalogue.

curl -X POST \
"https://auth.ohauthcat.com/v1/sso/token" \
-H "Authorization: Bearer $OHAUTHCAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"grant_type": "authorization_code",
"code": "01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
"client_id": "client_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"redirect_uri": "https://app.acme.com/callback"
}'
Response 200
{
"access_token": "sk_test_example",
"token_type": "Bearer",
"expires_in": 600,
"profile": {
"claims": {},
"risk": {
"score": 0,
"reasons": [
"impossible_travel"
],
"degraded": true
},
"custom_attributes": {},
"policy_hints": {
"force_sso": true,
"force_sso_excluded": true,
"max_age_seconds": 1,
"idp_initiated_allowed": true,
"guest": true
},
"access_policy": "guest",
"email_verified": true,
"idp_groups_verified": true,
"id": "prof_01J9ZQ4M7K2X8V3N5B6C1D0E9F",
"object": "profile",
"organization_id": "org_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"connection_id": "conn_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
"connection_type": "saml",
"idp_id": "0oa1b2c3d4E5F6g7h8i9",
"email": "jane@acme.com",
"email_domain_verified": true,
"first_name": "Jane",
"last_name": "Doe",
"groups": [
"Engineering"
],
"role": "admin",
"attributes": {},
"raw_attributes": {},
"legacy_ids": {
"workos": "org_01H8ZQ4M7K2X8V3N5B6C1D0E9F"
}
}
}