Auth

How people sign in to your app, and how Oalo proves who they are.

How people sign in to your app, and how Oalo proves who they are.

The short version

End users sign in with their email and a 6-digit code (a one-time passcode). There is no password. On success the server issues a signed token (a JWT) that the app carries on every request. That token also carries the user's entitlements (what they have paid for), which is how premium content stays locked. See commerce.md for the entitlement side.

Basic email sign-in ships wired into every app template. There is nothing to configure.

How email sign-in works

  1. The user enters their email. The server generates a 6-digit code, stores it with a 10-minute expiry, and emails it. A new code replaces any earlier one. At most 3 codes go to one email, and 20 to any addresses from one client, in 10 minutes.
  2. The user enters the code. Five wrong codes lock that email out for 10 minutes, and a new code doesn't lift the lock. On the right code the server marks it used, finds or creates the user record, and issues:
    • an access token (a JWT, valid about 1 hour),
    • a refresh token (valid 30 days),
    • a session, and the user object.
  3. The app stores the token and refreshes it ahead of expiry (the templates refresh roughly every 45 minutes) so the live sync socket never re-auths with an expired token. Each refresh returns a new refresh token too, and the old one stops working, so store both every time.
  4. Signing out (/logout with the current access token) ends the session: that token and its refresh token stop working at once.

The JWT is signed with a secret only the server holds. Its claims include the user id, email, username, org, session, and the entitlement claims has_pro and purchased_products. Those entitlement claims are baked in at sign-in time. That is the seam between auth and commerce. A user's completed orders become claims on their token, and both the server and the app read those claims to unlock content.

Signing in with a phone

If you connect your own text message provider (Twilio or Telnyx), your apps can also offer sign-in by phone: the person enters their number, gets a 6-digit code by text, and is signed in. It's off until you connect a provider and turn it on, and it's limited to the countries you pick. See Text messages (SMS).

  • An account can have an email, a phone, or both; either one signs in. Adding the second needs a code sent to it first. A number or email that already belongs to another account is refused.
  • An account with only a phone has no email, so email notifications skip it.
  • Your team always signs in to the dashboard by email.

End users vs your team

  • You and your team build the apps. You sign in to the Oalo dashboard as workspace members.
  • An end user (or "member") is a person using one of your apps. Your workspace has its own end-user roster, separate from every other workspace.

The dashboard has an Auth node that shows the roster: who signed up, how recently they were active, and how engaged they are. Your team signs in the same way, so its people are on the list too, tagged Team. Someone who signed in by phone shows their number.

What a member's sign-in can reach

Anyone can sign in to your app: that's what the email code is for. So a member's token only reaches what is theirs:

  • their own rows in your app's data, their orders and courses, and their own chats and calendar (through a chat token, below),
  • never your dashboard, your team's tools (imports, invitations, settings) or another member's data. Signing in never makes someone part of your team; only an invitation does, with the access the invitation gives.

Test your app with a member account, not your own: a token from your team's email also works in your dashboard.

In the app templates

Every scaffold ships an auth module:

  • AuthProvider (mounted at the app root) plus a useAuth() hook that exposes requestCode, verifyCode, signOut, refreshUser, getToken, and the current user.
  • RequireAuth, a wrapper that shows a login screen when the user is not signed in and the wrapped content once they are. It can gate one route or the whole app.

React, Expo, and Flutter all have the same shape (Flutter uses Riverpod).

Advanced: signing in with an outside identity provider

A chatbot can accept end users who are already signed in somewhere else (Firebase, Auth0, or a custom system) instead of Oalo's email codes. This uses a token exchange:

  • The public client calls POST /api/v1/chat/token with a non-secret public_bot_id and the user's existing credential.
  • The server verifies that credential. It tries two verifiers, chosen by the bot's config: Oalo-native (the email-code JWT above) or an external verifier, which runs the bot's own small sandboxed program (an "auth tool") that validates a Firebase/Auth0/etc token and returns the user's identity.
  • On success it returns a user-bound token for the Conversations API that lasts an hour, tied to that identity (external_ref). A bound token can only touch its own user's data. Only a published bot takes the exchange.
  • An Oalo sign-in that has expired or been signed out answers 401 end_user_unauthorized: refresh it and exchange again. Signing out doesn't end a chat token already exchanged; it runs out within its hour.

This is how a bot embedded in someone else's app can trust that app's logins.

Step by step

  1. Nothing to set up for basic sign-in. Email codes work out of the box. In the app, wrap the whole app or specific screens in RequireAuth. End users then sign in with email plus a 6-digit code.
  2. See who signed up in the dashboard Auth node (the app's user roster with recency and engagement).
  3. (Optional) Use an outside login for a chatbot. In the bot editor set the auth mode to "custom" and point it at a sandboxed auth tool that validates your IdP's tokens. The public client then exchanges an IdP token for a bound chat token via POST /api/v1/chat/token.
  4. (Optional) Authenticated chat. Pass the signed-in user's token into the chat widget so tools that require a signed-in user can run.

Notes for developers

  • Building your own frontend? The sign-in endpoints are POST /api/auth/request-code, /verify-code, /refresh-token and /logout on your Base. Connect your own frontend has the bodies, responses, token lifetimes and a working example.
  • Your app never creates or signs tokens. The Base issues the access token when a member verifies their code, and a new one on each refresh.
  • The server derives identity and scope from the token's claims, never from the request body, so a member can only reach their own rows.
Start with Oalo

Your own Base, with every feature, from $99 a month.

get started