Skip to main content

Sign Users In from a Native App

Exchange your user’s JWT for a Komo session token, then open the hub in your app’s web view with that token. No Komo SDK needed. For other ways to embed Komo in an app, see Mobile App Integration.

1. Set up the Workspace App

In the Komo Portal, go to Apps > Workspace Apps and open your app.
  • General: copy the App ID (for example au1_<app-guid> or us1_<app-guid>). Leave Allowed origins empty.
  • Authentication: turn on JWT, choose RS256 (JWKS URL or public key) or HS256 (shared secret), and set Issuer and Audience if you use them.
  • Claim Mapping: map your claims to contact fields, for example email to Email, first_name to First name, last_name to Last name.
  • Paste a sample token into JWT for testing to check it.

2. Exchange the JWT for a session token

Call the session API from your backend or app. Your JWT must have:
  • alg RS256 or HS256, matching the Workspace App.
  • iss and aud matching the app’s Issuer and Audience (if set).
  • exp. Keep it short-lived; the JWT is used once.
  • At least one claim you mapped on Claim Mapping (for example email).
  • kid only if you use a JWKS URL.
Your App ID starts with your region prefix (for example au1_ or us1_). Call https://api.{region}.komo.site and send the App ID without the prefix as appId. Sending the full App ID returns HTTP 400. This applies only when you call the session API directly. Komo’s web and React Native SDKs take the full App ID. Request:
Success response:
Failure response (also HTTP 200, so always check success):

3. Open the hub

Open the hub home page or any page in your app’s web view, with a fresh session token:
What happens:
  • The hub recognises the user as a known contact, so everything on it knows who they are: cards, their profile, loyalty and more. Forms can be prefilled or skipped using auto submit, and their profile is set up from your JWT claims.
  • Komo removes komo_session from the address bar and history. Other URL parameters, such as utm_source, are kept.
  • Opening the hub with a token for a different user switches it to that user.
  • The hub keeps recognising the user after the token’s 60 minutes. The token is used once; later opens without a token are still recognised through the hub’s long-lived cookie, as long as the web view keeps its data.

4. Refresh the session token (optional)

Only needed if your app keeps a session token to reopen the hub later. If you exchange a fresh JWT right before each open, skip this step. Request:
Response (a new token for the same contact):

5. Sign out

When a user signs out of your app, clear the web view’s cookies and website data for the hub domain.
If you don’t clear them, the previous user stays recognised on the hub, even if the next person opens it without a token.

Good to know

  • The user changes in your app: exchange a token for the new user and open the hub with it.
  • Invalid or expired session token: the hub loads with no error and keeps recognising whoever it already knew, which is why step 5 matters.
  • User agent: keep the web view’s default user agent, or append to it rather than replacing it.
  • Security: keep signing keys on your servers, and don’t log the session token or send it anywhere except the hub URL.

Need Help? Contact [email protected] for mobile integration assistance.