Introduction
Boxo Connect is a Single Sign-On (SSO) functionality that enables the host app to securely pass user profile information, allowing seamless authorization within the mini app. In essence, the Boxo Platform facilitates the transfer of user data from the host app backend to the mini app backend, ensuring smooth user authentication and returning a session token for continued access.
Boxo Connect flow
Here is diagram showcasing the hostapp user authorization inside miniapp
Authentication and User Authorization Flow
- User launches miniapp: The user opens the host app and launches the miniapp.
- Miniapp identifies the user and proceeds with the flow: The miniapp determines that user identification is needed to proceed.
- Miniapp calls
appboxosdk.login
JS SDK event: The miniapp requests a login action via Boxo’s JavaScript SDK.
- Consent screen is shown to the user: The user sees a consent dialog asking to “Allow miniapp to access your account information” with an “Allow” button.
- User makes a request to Super App’s Auth Gateway: After user consent, the system makes a request to the host app’s authentication gateway.
- Super App Server sends user data to Boxo Platform: The host app backend sends the user data to the Boxo Platform connect/ endpoint.
- Boxo Platform sends user data to Miniapp Server: The Boxo Platform forwards the user data to the miniapp backend.
- Miniapp Server generates authToken for user data: The miniapp backend processes the user data and generates an authorization token.
- authToken is returned to Super App: The token is also provided back to the host app.
- authToken is returned to miniapp: The authorization token is sent back through the chain to the miniapp frontend.
- User is authorized in miniapp server: The miniapp server authorizes the user using the token.
- User proceeds with the flow: The user is successfully authorized and can continue using the miniapp.
This process ensures a secure and seamless flow for user authorization between the host app, Boxo platform, and miniapp.
Setting up the backend
*Note: Feature must be enabled in Dashboard Partnership
Data format
Currently, data exchange is conducted in JSON format. String size limits are defined within the respective data types.
Connect endpoint
This endpoint is called by the Super App (partner) server to connect a user to a miniapp on the Boxo Platform. On success, it returns an authorization token pair for the miniapp session.
URL and METHOD
- HTTPS POST
/api/v1/connect/
(Boxo Platform)
Headers
Key | Value |
---|
Content-type | application/json |
Authentication to this endpoint is managed via your partnership configuration in the Dashboard (e.g., IP whitelisting or Request Signaturing). Follow your integration setup.
Request Body
Field | Data type | Optional | Description |
---|
client_id | String | No | Hostapp identifier |
app_id | String | No | Miniapp identifier |
user_data | UserData | No | User information object |
UserData
Field | Data type | Optional | Description |
---|
reference | String | No | Reference to user in Hostapp Server |
email | String | Yes | Verified user email address |
phone | String | Yes | Verified user phone number in E.164 format |
first_name | String | Yes | User’s first name |
last_name | String | Yes | User’s last name |
custom_attributes | JSON | Yes | Custom attributes |
Response
- Response status
200
for success, 400
for errors
- Response body:
Success Response (200):
Field | Data type | Description |
---|
token | String | Auth token |
refresh_token | String | Refresh token |
Error Response (400):
Field | Data type | Optional | Description |
---|
error_code | String | No | Error code |
error_message | String | No | Detailed error message |
exception | String | Yes | Exception details if available |
custom_attributes | Object | Yes | Additional error context |
Request Example
curl --location --request POST '[BOXO_PLATFORM_SERVER_URL]/api/v1/connect/' \
--header 'Content-Type: application/json' \
--data-raw '{
"client_id": "{{CLIENT_ID}}",
"app_id": "{{MINIAPP_ID}}",
"user": {
"reference": "{{USER_REFERENCE}}",
"email": "john@example.com",
"phone": "+11234567890",
"first_name": "John",
"last_name": "Doe",
"custom_attributes": {}
}
}'
WARNING For Shopboxo miniapps either email
or phone
must be provided
Success Response (200)
{
"token": "<AUTH_TOKEN>",
"refresh_token": "<REFRESH_TOKEN>"
}
Error Response (400)
{
"error_code": "INVALID_INPUT",
"error_message": "Missing required field: app_id",
"exception": null,
"custom_attributes": null
}
Required fields
Each mini app requires a set of minimum fields to create a user within its system and generate a session for the newly created user. The specific required fields for each mini app can be found in its details on the Showroom page.
Below is a list of all possible fields:
- email
- phone
- first_name
- last_name
- custom_attributes
Setting up the SDK
Initialization
Parameter Descriptions:
Within the SDK, there are specific parameters and methods that must be either provided or implemented to ensure proper functionality.
app_id
- Boxo miniapp app id
To launch a specific mini app, you must first call the initialization method.
iOS
let miniapp = Boxo.shared.getMiniapp(appId: "app_id")
miniapp.delegate = self
miniapp.open(viewController: self)
...
extension ViewController : MiniappDelegate {
func onAuth(miniapp: Miniapp) {
//send a request to backend to fetch tokens
miniapp.setAuthTokens(["token" : "<token>", "refresh_token" : "<refresh_token>"])
}
}
Android
val miniapp = Boxo.getMiniapp("app_id")
miniapp.setAuthListener { boxoActivity, miniapp ->
//use boxoActivity to open dialogs or activity
//send a request to backend to fetch tokens
miniapp.setAuthTokens(mapOf(
"token" to "<token>",
"refresh_token" to "<refresh_token>"
))
}
miniapp.open(activity)
Flutter
Boxo.openMiniapp('app_id');
Boxo.lifecycleHooksListener(
onAuth: (appId) { // called when authorization flow starts
//send a request to backend to fetch tokens
Boxo.setAuthTokens({
'token': '<token>',
'refresh_token': '<refresh_token>'
});
}
);
ReactNative
Boxo.openMiniapp('app_id')
Boxo.lifecycleHooksListener({
onAuth: (appId: string) => {
//send a request to backend to fetch tokens
Boxo.setAuthTokens({
'token': '<token>',
'refresh_token': '<refresh_token>'
});
},
});
WARNING
When a user logs out of the host app, ensure that the WebView cache is cleared using the following commands: Boxo.logout()
for Android or Boxo.shared.logout()
for iOS so that the miniapps’ storage is also cleared to log out the miniapp users as well.
Get user consent
This is Boxo endpoint to get status of user consent in Boxo Platform
URL and METHOD
- This is HTTPS GET
/api/v1/accounts/consent/get_consent/
endpoint
Query Parameters:
Parameter | Data type | Optional | Description |
---|
client_id | String | | Hostapp identifier |
app_id | String | | Miniapp identifier |
user_reference | String | | Reference to user in Hostapp Server |
Response: | | | |
{
“is_consented”: <Bool>
}