WeChat Mini Program Login
Call this API when logging in with a WeChat Mini Program.
Request Description
POST https://{your_domain}/api/v2/sdk/login/wechat-miniprogram
Request Headers
| Parameter Name | Name | Required | Type | Example |
|---|---|---|---|---|
| X-operating-sys-version | Caller client OS version | Yes | String | windows10.1.1 |
| X-device-fingerprint | Caller client device fingerprint | Yes | String | 156aysdna213sc50 |
| X-device-ip | Caller client IP | No | String | 192.168.1.2 |
| X-agent | User-Agent information | Yes | String | Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) |
| X-L | Used for international language settings | No | String | zh |
| X-client-id | Application authorization ID | Yes | String | nTo1eRIub60vPb54WeE6aojPwYwImtl4 |
| content-type | Content format type | Yes | String | application/json |
Request Example
json
{
"code":" 091zQTFa1i6qMC02AWFa1Vzt0O0zQTF8"
}Request Parameters
| Parameter Name | Name | Required | Type | Description |
|---|---|---|---|---|
| code | WeChat Mini Program login code | Yes | String | Login code returned by WeChat Mini Program login |
Response Examples
Success Example 1 (Successful user match returns session_token and id_token)
HTTP/1.1 200 OK
json
{
"session_token": "btsiBjx85prcZu6I6Ki057Tmw3nSF2VO",
"expire": 432000,
"status": "SUCCESS",
"id_token": "eyJraWQn0.eyJpc3MiOiJodHR…g1A7jG8O0uw"
}Success Example 2 (Returns auto-registration and binding flow)
HTTP/1.1 200 OK
json
{
"state_token": "eyJhbGcCJ9.eyJzdWMCJ9…tL2VPS8",
"data": "{\"socialBindOrRegisterFlow\":[\"VERIFY_PHONE\",\"VERIFY_EMAIL\"]}",
"status": "USER_REGISTER"
}Success Example 3 (Returns binding flow)
HTTP/1.1 200 OK
json
{
"state_token": " eyJhbGcCJ9.eyJzdWMCJ9…tL2VPS8",
"data": "{\"socialBindOrRegisterFlow\":[\"VERIFY_PHONE\",\"VERIFY_EMAIL\"]}",
"status": " SOCIAL_BIND"
}Response Parameters
| Parameter Name | Name | Type | Description |
|---|---|---|---|
| status | Login flow status identifier | String | SUCCES: Login successful SOCIAL_BIND: Binding flow. Choose a binding method: WeChat Authorized Mobile Binding User; Other Mobile Binding User; Username and Password Binding User USER_REGISTER: Binding or registration flow. Choose a binding method: WeChat Authorized Mobile Binding or Registering User; Other Mobile Binding or Registering User ACCESS_DENIED: Access denied MFA_AUTH: Secondary authentication |
| expire | session_token validity period | Number | session_token validity period |
| session_token | User session_token | String | User session_token |
| state_token | Login state token | String | Token with state, used in the flow of binding WeChat openid to the user's mobile number or username |
| data | Return description | String | Tenant social registration and binding flow configuration information. The socialBindOrRegisterFlow field contains the verification methods supported by the tenant.VERIFY_PHONE: Mobile number + SMS verification code VERIFY_EMAIL: Email + email verification code |
| id_token | Identity token of logged-in user, short-term valid | String | This field is in JWT format and contains user identity information. You can refer to Get User Info from id_token to obtain user information. The token validity period defaults to 5 minutes. |