Rialto

Authentication

Token exchange flow, API key usage, ID token requirements, and IdP-specific notes.

Rialto uses a token exchange pattern: your users authenticate with your identity provider, and you exchange their ID token for Rialto tokens.

Token Exchange Flow

User ──► Your App ──► Your IdP ──► ID Token

                         POST /identity/auth/exchange
                         X-API-Key: rialto_ak_...
                         { "token": "<id_token>" }


                              Rialto Identity
                         (validates JWT via OIDC/JWKS)


                         { access_token, refresh_token }
  1. User authenticates with your IdP
  2. Your backend obtains the user's ID token
  3. Your backend calls POST /identity/auth/exchange with the ID token and your X-API-Key
  4. Rialto validates the JWT signature via OIDC discovery and JWKS
  5. User is auto-created on first exchange (linked by email)
  6. Rialto returns an access_token and refresh_token

API Key

Your API key identifies your organization on every token exchange request.

DetailValue
HeaderX-API-Key
Formatrialto_ak_<org_id>_<random>
IssuedOnce, during IdP registration
RetrievableNo -- store it securely at issuance

The API key identifies your organization. The ID token identifies the user. Both are required.

Token Exchange Request

curl -X POST https://api.rialto.com/identity/auth/exchange \
  -H "Content-Type: application/json" \
  -H "X-API-Key: <your_api_key>" \
  -d '{ "token": "<id_token>" }'

Response (200):

{
  "access_token": "eyJhbGciOiJSUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 300,
  "refresh_token": "eyJhbGciOiJIUzI1NiIs...",
  "refresh_expires_in": 1800,
  "scope": "openid email profile aud:identity aud:primary-issuance"
}

Rialto Token Claims

The access_token includes these custom claims:

ClaimTypeDescription
org_idstring (UUID)Your organization ID
org_namestringYour organization name
user_idstring (UUID)Rialto user ID
emailstringUser's email
onboarding_completedbooleanUser finished onboarding
kyc_completedbooleanUser passed KYC verification
accreditedbooleanUser is accredited
accreditation_verifiedbooleanAccreditation has been verified

Use these claims to gate UI features. For example, check kyc_completed and accredited before allowing a user to subscribe to offerings.

Token Lifetimes

TokenLifetimeWhat to do when expired
Access token~5 minutesUse the refresh token
Refresh token~30 minutesExchange a fresh ID token from your IdP

ID Token Requirements

Your ID token must meet these requirements:

RequirementDetail
FormatJWT (three dot-separated base64 parts)
sub claimRequired -- the user's external ID
Email claimRequired -- one of: email, preferred_username, or upn
iss claimMust match the IdP URL registered for your organization
SignatureValid against your IdP's JWKS (fetched via OIDC discovery)
ExpiryMust not be expired

IdP-Specific Notes

AWS Cognito

Use the ID token (token_use: "id"), not the access token (token_use: "access"). Cognito access tokens do not contain the email claim.

  • Issuer URL: https://cognito-idp.<region>.amazonaws.com/<user-pool-id>
  • The token exchange endpoint will detect access tokens and include a hint in the error message

Auth0

Auth0 ID tokens are always JWTs and include email by default.

  • Issuer URL: https://<tenant>.auth0.com/
  • Ensure the email scope is requested during authentication

Okta

  • Issuer URL: https://<org>.okta.com/oauth2/default
  • If using a custom authorization server, the issuer URL will differ

Azure AD / Entra ID

  • Issuer URL: https://login.microsoftonline.com/<tenant-id>/v2.0
  • Ensure the email claim is included (may require configuring optional claims)

Google

  • Issuer URL: https://accounts.google.com
  • ID tokens always include email when the email scope is requested

Audience Scopes

When your organization was registered, audience scopes were configured (default: ["identity"]). The exchanged Rialto token includes these as aud:<scope> in the scope field:

scope: "openid email profile aud:identity aud:primary-issuance"

To update your audience scopes, contact Rialto staff or use:

PATCH /identity/auth/idp/<org_id>
{ "audience": ["identity", "primary-issuance", "custom-scope"] }

The "identity" audience is always included.

Error Reference

Error CodeStatusDescriptionFix
missing_api_key401X-API-Key header not providedAdd the X-API-Key header
invalid_api_key401Key is invalid or does not match an orgCheck the key value; contact Rialto if lost
invalid_token400Token is not a JWT, or missing sub/emailUse an ID token with required claims
invalid_signature401JWT signature verification failedEnsure token is freshly issued; JWKS keys may have rotated
token_expired401The ID token has expiredExchange a fresh token from your IdP
invalid_issuer401Token issuer is not trustedEnsure the iss claim matches your registered IdP URL
discovery_failed502Could not fetch OIDC configuration from issuerVerify your IdP's discovery endpoint is accessible
issuer_not_registered403IdP not registered with RialtoContact Rialto to register your IdP
org_mismatch403API key org doesn't match the token's issuer orgUse the correct API key for your IdP

On this page