Auth
Exchange token
Exchange an OIDC ID token from your identity provider for a Fire spark access token for the authenticated customer.
POST
The Storefront API supports OAuth 2.0 Token Exchange (RFC 8693) for public clients. Your app, web, or kiosk sends the customer’s OIDC ID token and receives a short-lived Fire spark access token in return.
No
Fire spark matches
client_id or client_secret is required. Fire spark reads the ID token’s iss and aud claims, finds the merchant’s configured identity provider, validates the token against that provider’s JWKS, and issues an access token bound to the customer identified by the sub claim.
When to use token exchange
Use this endpoint when:- Customers sign in with an OIDC-compliant identity provider on the client
- Your channel needs to call the Storefront API on behalf of that customer
- You want Fire spark to validate identity and limit API access to a single customer
Prerequisites
- Configure your identity provider in the Fire spark dashboard for your merchant.
- Authenticate the customer on the client and obtain a fresh OIDC ID token from your provider.
How it works
Customer signs in on the client
Your app completes sign-in with your OIDC provider using that provider’s client
SDK. Retrieve the ID token the provider issues for the authenticated session.
Client sends the ID token
Your client calls
POST /auth/exchange with the ID token as subject_token.
No merchant ID or API secret is needed in the request.Fire spark resolves the merchant and validates the token
Fire spark matches the token’s
iss and aud to the provider configured for
a merchant, verifies the signature and expiration using that provider’s JWKS,
and reads sub as the customer’s external identifier.Obtain the ID token
Each provider exposes the ID token through its client SDK. Use the method that returns the JWT ID token for the current session.- Auth0
- Clerk
- Supabase
- Firebase
- Amazon Cognito
- Okta
Token exchange request
Send aPOST request to /auth/exchange with Content-Type: application/json. The request body is the same regardless of provider.
Request body
| Field | Required | Description |
|---|---|---|
grant_type | Yes | Must be urn:ietf:params:oauth:grant-type:token-exchange. |
subject_token | Yes | The OIDC ID token from your identity provider for the signed-in customer. |
subject_token_type | Yes | Must be urn:ietf:params:oauth:token-type:id_token. Opaque access tokens are not accepted. |
How Fire spark identifies the merchant
Fire spark does not require a merchant ID in the request. It inspects the ID token claims:| Claim | Purpose |
|---|---|
iss | Identifies the identity provider issuer URL. |
aud | Identifies the provider project, realm, or app client. |
sub | Stable customer identifier used to resolve or create the customer record. |
iss and aud against the provider configuration registered for a merchant, then validates the token signature before issuing an access token.
Supported providers
Any OIDC-compliant provider that issues JWT ID tokens with a discoverable JWKS endpoint is supported. Register the provider in the dashboard before going to production.| Provider | Typical iss format | How to get the ID token |
|---|---|---|
| Auth0 | https://{tenant}.auth0.com/ | getIdTokenClaims().__raw |
| Clerk | https://{your-clerk-domain} | getToken() |
| Supabase | https://{project-ref}.supabase.co/auth/v1 | getSession().access_token |
| Firebase | https://securetoken.google.com/{projectId} | getIdToken() |
| Amazon Cognito | https://cognito-idp.{region}.amazonaws.com/{userPoolId} | fetchAuthSession().tokens.idToken |
| Okta | https://{okta-domain}/oauth2/{authorizationServerId} | tokenManager.get("idToken") |
| Keycloak | https://{host}/realms/{realm} | keycloak.idToken |
The
iss and aud values must match exactly what Fire spark has on file for
your merchant. Copy them from a decoded ID token when configuring the provider
in the dashboard.Use the exchanged token
Include the Fire spark access token in theAuthorization header. The token only grants access to resources for the customer linked to the original sub claim.
Re-exchange when your provider refreshes the ID token. Fire spark access tokens
are short-lived and are not a replacement for keeping the IdP session current.
Security properties
- Public client profile: Designed for mobile and web clients. No confidential credentials are sent or stored in the app.
- ID token only: Only OIDC JWT ID tokens are accepted as
subject_token. Opaque or provider API tokens are rejected. - Cryptographic validation: Signature,
iss,aud, andexpare verified against the merchant’s registered provider before any customer data is returned. - Customer isolation: The issued access token is bound to the
subfrom the ID token. Requests for other customers are rejected. - Short-lived tokens: Exchanged tokens expire after
expires_inseconds.
Error responses
Errors follow RFC 6749 and RFC 8693. The endpoint returnsapplication/json with an error field.
| Error | Description |
|---|---|
invalid_request | A required field is missing or malformed. |
invalid_grant | The ID token is invalid, expired, or does not match any registered provider for a merchant. |
unsupported_grant_type | The grant_type value is not supported. |
Error