# Unified Login Guide
To address login challenges for Mini-Program ecosystem partners deploying across multiple Host-Apps, FinClip provides an adaptable Mini-Program login solution.
The Host-App injects a unique user identifier and sets its channel name. The Mini-Program can then integrate a plugin to obtain a code via wx.login, which is decrypted by the Mini-Platform to retrieve the channel, unique user ID (openId), and optional global user ID (unionId).
# Host-App Integration
# iOS
Simply configure currentUserId, channel, and phone in FATConfig during SDK initialization. (Requires upgrade to version 2.45.1)
Sample code:
FATConfig *config = [FATConfig configWithStoreConfigs:storeArrayM];
config.currentUserId = @"xxxx";
config.channel = @"finclip";
config.phone = @"appid";
# Android
Simply configure currentUserId, channel, and phone in FATConfig during SDK initialization. (Requires upgrade to version 2.45.1)
Sample code:
val config = FinAppConfig.Builder()
.setUserId("xxxx")
.setChannel("finclip")
.setPhone("12345678901")
.build()
# HarmonyOS
Simply configure currentUserId, channel, and phone in FinAppConfig during SDK initialization. (Requires upgrade to version 1.0.2)
Sample code:
const finAppConfig: IFinAppConfig.IFinAppConfig = {
// ...
phone: '12345678901',
currentUserId: 'xxxx',
channel: 'finclip'
}
# uni-app
Login Integration
Simply configure userId, channel, and phone in the options during plugin SDK initialization (Integration Documentation). (Update to the latest plugin version (download from GitHub/Gitee) and rely on the latest core SDK version 2.45.5)
Sample code:
MopSdk.initialize({
finStoreConfigs:[
{'sdkKey': 'xxxxxx',
'sdkSecret': 'xxx',
'apiServer': 'https://xxx.com'}]},
userId: 'xxxx',
channel: 'finclip',
phone: '135xxxxxxx',
(ret) => {
console.log('App Launch Success', ret)
},
(ret) =>{
console.log('App Launch Fail', ret)
});
Grayscale Release
Configure the grayscale matching value for reporting Documentation Center
//For gender/age matching, report information as follows:
const options = [{key: 'sex',value: '男'},{key: 'age',value: 18 }]
MopSdk.setGrayAppletVersionConfigs(options)
Note: To ensure proper injection of currentUserId, phone, etc., in FATConfig, the Host-App should verify login status before launching the Mini-Program (If configuration injection fails, calling wx.login in the Mini-Program will trigger the fail callback, and the bindgetphonenumber event callback will only return error information).
# IDE Integration
Configure the userId, channel, and phone information in the "Global Field Configuration" section.

# Mini-Program Integration
Mini-Program demo:
login-demo.zip (opens new window)
# Configure Plugins in app.json
"plugins":{
"loginPlugins": {
"version": "1.0.6",
"provider": "2275269218722181"
},
"getPhoneNumberPlugins": {
"version": "1.0.4",
"provider": "2275270855598469"
}
}
# Login
- The Mini-Program calls
wx.login; the plugin automatically intercepts and returns an encryptedcode. - The
successcallback of thelogininterface returnscode,appid, andapiserver. - The business service calls the following Mini-Program service interface to obtain the user's
openIdandunionId.
POST {Mini-Program Server apiserver}/api/v1/open/dev/mini-apps/unified-auth/login
Request Parameters
Parameter Location: header
| Field | Type | Meaning | Remarks |
|---|---|---|---|
| Authorization | string | Bearer {personalAccessToken} | personalAccessToken is generated in the Personal Center of the Developer Center. Ensure the "Mini-Program Unified Authentication" scope is selected. |
Parameter Location: body
| Field | Type | Meaning |
|---|---|---|
| appId | string | Mini-Program ID |
| code | string |
Response Parameters
| Field | Sub-field | Type | Meaning |
|---|---|---|---|
| data | channel | string | Channel |
| openId | string | Unique User ID | |
| unionId | string | Global User ID | |
| errcode | |||
| error |
Final Request Example
POST {Mini-Program Server apiserver}/api/v1/open/dev/mini-apps/unified-auth/login
Body application/json
{
"appId":"fc2183741419665349",
"code":"1drac2l7scWpTtetZtF4tA02llZegeLbJSxTYTUG6MmjBA2L3xewOk7IjSqY72ZNDsvWKU0r2EdLKcLqS82g0EKnDgE0uSu1REmvFpPIF8Y="
}
Response
{
"error": "",
"errcode": "OK",
"data": {
"channel": "com.finogeeks.finosprite",
"openId": "2279547539610117",
"unionId": "5110c76fbc1c8ebc7429e906b83c1f7f",
"accessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImNlcnQtYnVpbHQtaW4iLCJ0eXAiOiJKV1QifQ.eyJvd25lciI6ImNvbS5maW5vZ2Vla3MuZmlub3Nwcml0ZSIsIm5hbWUiOiIyMjc5NTQ3NTM5NjEwMTE4IiwiY3JlYXRlZFRpbWUiOiIyMDI0LTA3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ent'sopen-type=getPhoneNumberand bind thebindgetphonenumberevent in the Mini-Program. Clicking thebuttoncomponent returns an encryptedcode. - The
bindgetphonenumberevent is triggered, returningcode,appid, andapiserver. - The business service calls the following Mini-Program service interface to obtain the user's phone number.
POST {Mini-Program Server apiserver }/api/v1/open/dev/mini-apps/unified-auth/phone/get
Request Parameters
Parameter Location: header
| Field | Type | Meaning | Remarks |
|---|---|---|---|
| Authorization | string | Bearer {personalAccessToken} | personalAccessToken is generated in the Personal Center of the Developer Center. Ensure the "Mini-Program Unified Authentication" scope is selected. |
Parameter Location: body
| Field | Type | Meaning |
|---|---|---|
| appId | string | Mini-Program ID |
| code | string |
Response Parameters
| Field | Sub-field | Type | Meaning |
|---|---|---|---|
| data | phone | string | Phone Number |
| errcode | |||
| error |
Final Request Example
POST {Mini-Program Server apiserver}/api/v1/open/dev/mini-apps/unified-auth/phone/get
Body application/json
{
"appId":"fc2183741419665349",
"code":"1drac2l7scWpTtetZtF4tA02llZegeLbJSxTYTUG6MmjBA2L3xewOk7IjSqY72ZNDsvWKU0r2EdLKcLqS82g0EKnDgE0uSu1REmvFpPIF8Y="
}
Response
{
"error": "",
"errcode": "OK",
"data": {
"phone": "13333333333"
},
"traceid": "8a272339cf6f4e72bec6efa3a11a42e7"
}