Skip to main content
Version: v1

Super App Integration

Overall Flow

info

This is an example is almost follow the authentication method when integrate between Mini App and Telegram

Overall Flow

info

Below is an example on how to generate a initData for the authentication flow

Code Sample

func main() {
secret := "<tenant_api_key>"
tenantPlayerID := "<tenant_player_id>"
tenantPlayerToken := "<tenant_player_token>"
playerName := "<player_name>"
avatar := "https://example.com/avatar.jpg"
authDate := time.Now().Unix()

params := map[string]string{
"tenant_player_id": tenantPlayerID,
"tenant_player_token": tenantPlayerToken,
"name": playerName,
"avatar": avatar,
"auth_date": fmt.Sprint(authDate),
}

var hashParams []string
for k, v := range params {
if len(v) > 0 {
hashParams = append(hashParams, fmt.Sprintf("%s=%s", k, v))
}
}
sort.Strings(hashParams)

hashKey := sha256.New()
hashKey.Write([]byte(secret))
hmac := hmac.New(sha256.New, hashKey.Sum(nil))
hmac.Write([]byte(strings.Join(hashParams, "\n")))
hash := hex.EncodeToString(hmac.Sum(nil))
params["hash"] = hash

v, _ := json.Marshal(params)
fmt.Println(string(v))
}

Load Mini App via URL in Super App

Simple, flexible, native-like web applications to enhance user experience

URL Scheme to load
URL: {miniapp_domain}/?platform=seamless#seamlessAuth={seamlessAuth}
Parameter nameData TypeMandatoryDescription
miniapp_domainStringYesProvided to you on your N11s Back Office
seamlessAuthStringYesA string with raw data transferred to the Mini App, convenient for validating data. This value must be encoded.
Example:
- Use Javascript: encodeURIComponent(initData).
- Use Go: url.QueryEscape(initData)