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
Headers
Section titled “Headers”
Minor version; defaults to the environment’s pin.OhAuthCat-Versionstring
Honoured for 24 h; a replay returns the original response.Idempotency-Keystringmin length 1 · max length 255
Request body
Section titled “Request body”grant_typestring Requiredone of
authorization_codecodestring Requiredmin length 1
code_verifierstring Requiredmin length 43 · max length 128
The publishable key (pk_…) the code was requested with on /sso/authorize.client_idstring Requiredmin length 1
redirect_uristring (uri) Required
Responses
Section titled “Responses”- 200 OK SsoToken
- 400 Invalid request. Codes: parameter_invalid, parameter_missing, version_unsupported and resource-specific codes from the catalogue. Error
- 401 Codes: authentication_required, api_key_invalid. Error
- 403 Codes: api_key_scope_missing, ip_not_allowed, plan_limit_reached. Error
- 409 Codes: idempotency_key_reused and resource-specific conflicts. Error
- 429 Code: rate_limited. Retry-After is set. Error
- 503 Code: service_unavailable. Retry-After is set; writes are paused. Error
- default Any other error, including internal_error. Every code is in the error catalogue. Error
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"}'const response = await fetch("https://auth.ohauthcat.com/v1/sso/token", { method: "POST", headers: { Authorization: `Bearer ${process.env.OHAUTHCAT_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "grant_type": "authorization_code", "code": "01J9Z3K5V7W8X9Y0Z1A2B3C4D5", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "client_id": "client_01J9Z3K5V7W8X9Y0Z1A2B3C4D5", "redirect_uri": "https://app.acme.com/callback" }),});const data = await response.json();import osimport requests
response = requests.post( "https://auth.ohauthcat.com/v1/sso/token", headers={"Authorization": f"Bearer {os.environ['OHAUTHCAT_API_KEY']}"}, json={ "grant_type": "authorization_code", "code": "01J9Z3K5V7W8X9Y0Z1A2B3C4D5", "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", "client_id": "client_01J9Z3K5V7W8X9Y0Z1A2B3C4D5", "redirect_uri": "https://app.acme.com/callback", },)data = response.json(){ "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" } }}