Notice
Our backend will make a request for creating a user and for getting an authorization token.
Prerequisites
- User authorization system
Boxo Connect flow
Boxo Connect flow
Here is diagram showcasing the hostapp user authorization inside miniapp
Here is the revised flow for better clarity:This process ensures a secure and seamless flow for user authorization between the host app, Boxo platform, and miniapp.

1
User launches miniapp
User opens host app and launches miniapp: The user opens the host app and starts the miniapp.
2
User identification required
User should be identified to proceed with the flow: This could involve product purchase, user registration, etc.
3
Miniapp calls login
appboxo.login() is called from inside the miniapp: The miniapp requests a login action via Boxo’s SDK.4
User consent requested
User is asked for confirmation to give access to personal data: The user is prompted to confirm sharing personal data necessary for the miniapp’s authorization process.
5
SDK retrieves auth code
Boxo’s native SDK gets the auth code generated by the host app: Boxo SDK receives the authorization code and sends an HTTPS request to the Boxo platform with the auth code.
6
Platform requests validation
Boxo’s platform sends an HTTPS request to the host app backend: The Boxo platform sends the auth code to the host app’s backend for validation.
7
Host app validates and returns token
Host app backend validates the auth code and returns an access token: The backend checks the auth code and sends back an access token.
8
Platform requests user data
Boxo’s platform sends an HTTPS request to the host app backend to get user data: The Boxo platform requests the user data from the host app backend using the access token.
9
Host app returns user data
Host app backend validates the access token and returns user data: The host app backend confirms the validity of the access token and sends the user data back.
10
Platform forwards to miniapp
Boxo’s platform sends an HTTPS request with the user data to the miniapp backend: Boxo platform forwards the user data to the miniapp backend for processing.
11
Miniapp processes user
Miniapp backend either registers a new user or identifies an existing one: The miniapp backend registers the user or identifies the existing user, then sends an authorization token back to Boxo platform.
12
Platform returns auth token
Boxo platform sends back the authorization token to the Boxo native SDK: The authorization token is sent back to the Boxo SDK that initiated the request.
13
Token passed to miniapp
Authorization token is passed to the miniapp: The token is provided to the miniapp.
14
Miniapp requests user data
Miniapp makes a request with the token to get user data from the miniapp backend: The miniapp sends the token to its backend for user data.
15
Backend returns user data
Miniapp backend recognizes the token and sends back user data: The miniapp backend verifies the token and returns the user data.
16
User authorized successfully
User is authorized and continues with the miniapp flow: The user is successfully authorized and can proceed with using the miniapp.
Setting up the backend
Setting up the backend
Note: Feature must be enabled in Dashboard Partnership

Generate Auth Token
Generate Auth Token
This endpoint is for the Boxo platform to send user data along with miniapp credentials and receive an authorization token in return.URL and METHOD:
Body:
Response:
In the backend, follow these steps:Add Get Token URL and Required Fields to miniapp settingsOn the My miniapps page, choose the miniapp, and go to settings. Enter Get Auth Token URL and Required field in the appropriate input fields.
- This endpoint must handle a HTTPS POST request
-
URL to endpoint must be provided in Dashboard

| Key | Value | |||
|---|---|---|---|---|
| Authorization | Basic <base64 encoded(app_id:secret_key)> | |||
| X-Hostapp-Client-ID | <client_id - Hostapp identifier> | |||
| X-Miniapp-App-ID | <app_id - Miniapp identifier> |
| Field | Data type | Description | ||
|---|---|---|---|---|
| reference | String(100) | Reference to user in Hostapp Server | ||
| String | Verified user email address | |||
| phone | String | Verified user phone number in E.164 format | ||
| first_name | String | User’s first name | ||
| last_name | String | User’s last name | ||
| custom_attributes | JSON | Custom attributes |
- Response status must be
200in all cases - Response body:
| Data type | Optional | Description | ||||
|---|---|---|---|---|---|---|
auth_token | String(1000) | No, except error_code provided | Authorization token for authenticating user in miniapp | |||
refresh_token | String(1000) | Yes | Refresh token for auth_token miniapp | |||
error_code | String | Yes | If some error is occured error code should be provided. Example: {"error_code": "INVALID_USER_DATA"} All error codes can be found here |
-
For new users:
- Create a new user account with the received inputs for new users. Use
referencefield as identifier. - Ensure that the new user account is identical to the regular user accounts within your authorization system.
- Create a new user account with the received inputs for new users. Use
-
For existing users:
- If the user already exists in your database, generate an authorization token for the user and return it.
-
Return the access token:
- At the end of the login process, generate an authorization token.
- The authorization token will serve as proof that the API calls made are from a specific user.
- You can also specify the session expiry time according to your preferences.
- You can also provide
refresh_tokenfor the session renewal without triggering connect flow again.
Authorizing users at different phases of miniapp experience
Authorizing users at different phases of miniapp experience
Logging out
Logging out
Whenever you need to logout the user, you can call the
logout() function, which will clear cookies and log out the user from the miniapp.Security
Security
You can secure the connection with the following methods.IP FilterYou can set up an IP filter to secure the connection between Boxo and your miniapp. For security purposes, you should only accept requests from Boxo’s verified IP address. This ensures that the requests are coming from Boxo’s trusted servers, adding an extra layer of protection to the communication.Authorization HeaderBoxo will send requests with a Basic Authorization header containing the app_id and secret_key provided in the Dashboard. These credentials ensure that the requests are authenticated and that only authorized applications can access the resources within the miniapp.