Skip to main content
Mini Apps run inside the Rebell SuperApp but execute in a client-side sandbox. For security and compliance reasons, the Mini App must be treated as an untrusted client, and every call from the Mini App to the merchant backend must be authenticated and authorized. This section describes the Rebell authorization-code pattern used to establish a trusted user context on the backend. This is the foundation for all other backend operations (orders, user profile access, payments, etc.).

Trust Model Overview

Actors

User

Rebell customer using the SuperApp

Mini App

Runs in Rebell SuperApp (untrusted)

Merchant Backend

Trusted system of record

Rebell OpenAPI

Trusted authorization provider

Key Rule

  • The Mini App can request authorization and carry an authorization code, but it cannot validate it
  • The Merchant Backend must exchange the code with Rebell OpenAPI to obtain a trusted user context

Why Mini Apps Cannot Be Trusted

Mini Apps must not be trusted because:
Therefore:
  • The backend must never trust userId or similar identifiers coming from the Mini App payload
  • The backend must use server-side verification via Rebell OpenAPI

Authorization Code (authCode) Concept

An authCode is a short-lived, single-use authorization artifact issued by Rebell after user consent.

Properties

What authCode Is NOT

The authCode expires quickly and cannot be stored for later use

What authCode Is Used For

To let the Merchant Backend exchange it for a trusted user context (and optionally a platform access token / user identifiers, depending on scope).

End-to-End Authorization Flow

Sequence Diagram

Flow Steps

1

Mini App Requests Authorization

Mini App calls JSAPI to request user authorization with specific scopes
2

User Grants Consent

Platform shows consent prompt; user approves or denies
3

Mini App Receives authCode

Platform returns short-lived, single-use authCode
4

Mini App Sends to Backend

Mini App sends authCode to merchant backend bootstrap endpoint
5

Backend Exchanges authCode

Backend exchanges authCode with Rebell OpenAPI (server-to-server, signed)
6

Backend Establishes Session

Backend creates internal session and returns session identifier to Mini App

Result

The backend now has a verified user context and can securely act on behalf of that user, within granted scopes.

Backend Token Exchange & Validation

Exchange Step (Mandatory)

When the backend receives authCode, it must:
1

Validate Format

Validate basic format (non-empty, expected length)
2

Exchange with Rebell

Exchange it with Rebell OpenAPI (server-to-server, signed request)
3

Validate Response

Validate the response:
  • Mini App identifier (if provided)
  • Granted scopes match what is required
  • Token/user context is not expired
4

Create Session

Persist a backend session context

Backend Exchange Implementation

What the Backend Should Store

Store a backend session record like:

Session Establishment Patterns

Choose one approach:
Important:
  • The Mini App must not send authCode again after bootstrap
  • The backend must treat authCode as single-use

Using the Authenticated Context

Once a session is established, every request from Mini App to backend should rely on the backend session to identify the user — not on client-provided identifiers.

Authenticated Request Flow

Backend Implementation

Key backend rule: Any request requiring user identity must use rebellUserId from session context, never from client-provided values.

Payments Built on Top of Backend Authorization

Payments inside Mini Apps should follow the same trust pattern:
1

Mini App Triggers

The Mini App triggers a payment action
2

Backend Creates Payment

The backend creates the payment (using session’s rebellUserId)
3

Webhook Confirms

The backend receives webhook confirmation
4

UI Updates

The Mini App UI updates based on backend-confirmed state

Payment Flow Sequence

Security Rules & Anti-Patterns

Hard Rules

Never:
  • Store secrets or private keys in Mini App code
  • Call Rebell OpenAPI directly from the Mini App
  • Trust userId or similar fields from the Mini App request body
  • Use authCode as a long-lived token
  • Mark order as paid based on client callback instead of webhook
Always:
  • Exchange authCode server-side and derive identity from OpenAPI response
  • Validate webhook signatures for payment confirmation
  • Use session context for user identity in all backend operations
  • Enforce session expiry and require re-authorization when needed

Anti-Patterns to Avoid

Backend Endpoint Reference

Bootstrap Endpoint

Request:
Responses:

Backend Must Enforce

Never accept the same authCode twice. Mark as used after successful exchange.
Don’t allow user-info access if scope not granted. Validate scopes match requirements.
If session expired, require re-authorization. Don’t extend sessions indefinitely.
Same paymentRequestId rules as Payment Integration chapter. Prevent duplicate payments.

Testing Authentication Flow

Test Checklist

  • User grants authorization
  • authCode exchanged successfully
  • Session created with correct user context
  • Subsequent requests use session correctly
  • User denies authorization
  • Invalid authCode format
  • Expired authCode
  • authCode reuse attempt
  • Session expiration
  • Client-provided userId is ignored
  • authCode cannot be replayed
  • Session is properly invalidated
  • Scopes are enforced

Next Steps

With backend authentication implemented, you can now integrate payments:

Payments in Mini Apps

Integrate payment functionality within your Mini App

Payment Integration

Review the complete payment integration guide