Build

Sign-in and identity

Users never create an account in your app. SALOPHA hands your page a one-time code, your server exchanges it, and you get a stable identifier that belongs to your app alone.

Last updated: November 7, 2026 · Browser SDK 1.6.0 · Bridge protocol 1.2

The flow#

  1. The user opens your app. SALOPHA creates a launch session and a one-time sign-in code.
  2. Your page calls requestAuthCode() and posts {code, launchSessionId, nonce} to your server.
  3. Your server calls exchangeCode() (or POST /v1/mini-apps/auth/token) with its client id and secret.
  4. SALOPHA answers with sub, the granted scopes, the profile fields the user agreed to share, and a user access token for 15 minutes.
  5. Your server creates its own session. SALOPHA tokens never reach the page.
// Page
const { code, launchSessionId } = await app.requestAuthCode();
await fetch("/api/v1/auth/salopha", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code, launchSessionId, nonce: app.launchNonce }) });

// Server
const r = await platform.exchangeCode({ code, launchSessionId, nonce });
// r = { sub, scopes, profile?: { displayName, phone?, avatarUrl?, locale?, city? }, accessToken }

The pairwise sub#

  • sub (pw_…) identifies the user for your app only. Two apps see two different values for the same person, so apps cannot link users across services.
  • It is stable: the same user always has the same sub in your app. Use it as your user key.
  • Never key users by phone number or name; those depend on consent and can change.

Codes and tokens#

ItemLifetimeNotes
Sign-in code60 seconds, single useReplaying a code revokes the launch session.
User access token15 minutesBound to the user; for me, addresses, transactions, businesses. Consent is re-checked on every call.
Server token15 minutesFrom your client credentials (aud miniapp-server:<appId>); for notifications, users and stats. The server SDK caches it. Rotating the secret ends old ones.

When your session expires, call requestAuthCode() again: after the first call it returns a fresh code without any UI, so re-authentication is silent.

Profile fields#

FieldNeedsNotes
displayNameprofile.basic
avatarUrlprofile.basicOnly when the user shows their photo to everyone.
locale, cityprofile.basicWhen set
phoneprofile.phoneVerified number. Automatic grants include it only when the user shows their number to everyone; otherwise ask with requestScope("profile.phone").

An app is never one of the user's contacts, so privacy settings that say «contacts only» always hide that field from apps.

Automatic sign-in#

Official apps and apps from trusted developers can list autoGrantScopes in the manifest, for example profile.basic, profile.phone and notifications.service. Users are then signed in without a consent sheet. They can still revoke each scope in Settings › Mini apps, and a revoked automatic grant stays revoked.

Other apps ask with requestScope(scope) right before they need something. See Scopes.

When consent is revoked#

When a user revokes your app's access, SALOPHA sends a signed webhook to <webhookUrl>/webhooks:

{ "eventType": "platform.consent.revoked.v1", "appId": "my_shop", "sub": "pw_7f3a9c", "pairwiseSub": "pw_7f3a9c", "scope": "profile.basic" }

End that user's sessions when scope is null or profile.basic. A simple way is a session version per user: bump it in the webhook and check it in your session guard. Treat the event as final and delete cached personal data you no longer may keep.

api.post("/api/v1/platform/webhooks", express.raw({ type: "*/*" }), async (req, res) => {
  const r = await platform.handlePlatformCall({ method: "POST", path: req.originalUrl, headers: req.headers, rawBody: req.body }, {
    webhook: async (event) => {
      if (event.eventType === "platform.consent.revoked.v1" && (!event.scope || event.scope === "profile.basic")) await users.bumpSessionVersion(event.sub);
    },
  });
  res.status(r.status).json(r.body);
});

Merchant staff#

People who manage a store or agency in your app sign in the same way. Decide their access on your server, never from the page: the owner sub stored on the record, staff of a SALOPHA business bound to your app (platform.businesses(accessToken) at sign-in), or a one-time claim code you issue. See Merchant bindings.