Skip to content

ExchangeSSOCode

Description: Exchanges a code created by CreateCustomerSSOCode or CreateAccountSSOCode for an ordinary customer or account session. This is normal SSO, not a manager impersonation session.

Access Control

🔓 No existing session required. Possession of a valid, unexpired code is required.

The request must resolve to the brand to which the code was issued. If request context does not identify the brand, pass the optional brand field following the existing API-brand selection convention. The server rechecks current issuer enablement, the issuer's permission and scope, target visibility and enablement, and brand API admission before it issues a session. The brand's configured terminal host must also be approved for terminal access. API admission alone does not satisfy this check, and the optional brand field does not override it.

Request Parameters

Name Type Required Description
code string Yes Exactly 64 lowercase hexadecimal characters from a normal SSO URL.
brand string No Explicit brand selector where allowed by the existing request-host/API-brand convention. It must resolve to the brand bound to the code.

Request Example

{
  "command": "ExchangeSSOCode",
  "extID": "sso-exchange-1",
  "data": {
    "code": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "brand": "default"
  }
}

Response Parameters

The fields below are returned inside data in the TCP response envelope. The server returns one identity shape according to the code subject.

Name Type Description
subject_type string customer or account.
customer_id integer Customer ID; present only for a customer session.
login integer Trading login; present only for an account session.
__token string Ed25519 session JWT, valid for the configured session_ttl_hours (24 hours by default).

Customer response:

{
  "extID": "sso-exchange-1",
  "status": 200,
  "data": {
    "subject_type": "customer",
    "customer_id": 1042,
    "__token": "<Ed25519 ion-session+jwt>"
  }
}

Account response:

{
  "extID": "sso-exchange-1",
  "status": 200,
  "data": {
    "subject_type": "account",
    "login": 123456,
    "__token": "<Ed25519 ion-session+jwt>"
  }
}

The session token expires according to session_ttl_hours (default 24). Customer responses do not include impersonated_by. For the token claims, see the session token profile.

Codes are single-use and expire after 60 seconds. An exchange attempt consumes a recognized code even if it resolves the wrong brand or later issuer/target checks fail. Codes are stored as hashes in bounded process memory, so a server restart invalidates outstanding codes.

Errors

Status Error Description
400 INVALID_DATA code is missing, is not exactly 64 characters, or brand is not a string.
400 SSO_CODE_INVALID_OR_EXPIRED Code is unknown, consumed, expired, malformed, or does not match the resolved request brand.
403 SSO_ACCESS_DENIED Issuer or target is disabled, issuer permission/scope was removed, or target visibility checks fail.
403 BRAND_NOT_AVAILABLE Target brand is not admitted for licensed API access.
503 LICENSE_NOT_ACTIVE A required active license lease is unavailable; no session token is issued.
503 SESSION_TOKEN_UNAVAILABLE The lease is active, but signing, authorization resolution, or SessionGuard cache/queue admission failed. Success does not wait for SQLite commit.

This command is separate from AuthCustomerByCode, which exchanges an older manager-created impersonation code.