The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

WeChat ID Registration and Login

Last updated: 2025-04-28 15:12:53

1. API Description

API request domain name: iot.cloud.tencent.com/api/exploreropen/appapi. This interface (AppGetTokenByWeiXin) is used for WeChat user registration and login to obtain the user access Token of the development platform. When called for the first time, it automatically registers a corresponding account for the WeChat ID.

2. Input Parameters

Name
Type
Required
Description
Action
String
Yes
Common parameter, this interface takes values: AppGetTokenByWeiXin.
RequestId
String
Yes
Common parameter, unique request ID, can be generated manually, uuid is recommended for use. Locating issues, need to provide the RequestId for the request.
AppKey
String
Yes
Common parameter, application AppKey, used to identify the corresponding mini program or app.
Signature
String
Yes
Common parameter, signature request, which needs to be generated by the user on one's own and is used for verifying the legitimacy of the request.
Timestamp
Int64
Yes
Common parameter, request's UNIX timestamp (in seconds).
Nonce
Int
Yes
Common parameter, a random positive integer, combined with Timestamp to prevent replay attacks.
WxOpenID
String
Yes
OpenID or UnionID of a WeChat user.
NickName
String
Yes
Nickname.
Avatar
String
Yes
Avatar.

3. Output Parameters

Name
Type
Description
RequestId
String
Common parameters, unique request ID, consistent with the input parameters.
ExpireAt
Int64
Deadline, UNIX second-level timestamp.
Token
String
AccessToken returned by the development platform. Use this Token to make api requests after logging in.

4. Samples

Input example
POST https://iot.cloud.tencent.com/api/exploreropen/appapi HTTP/1.1
content-type: application/json
{
"WxOpenID": "0123456789",
"NickName": "tests",
"Avatar": "http://example.com/path/to/avatar.jpg",
"Signature": "IY0yHX7zWCZKZ97xDonQoy16W4U=",
"Timestamp": 1552621825,
"Nonce": 2,
"Action": "AppGetTokenByWeiXin",
"AppKey": "ahPxdK*****TGrejd",
"RequestId": "rest-client"
}
Output example: successful
{
"Response": {
"Data": {
"ExpireAt": 1556076201,
"Token": "d2******************8514"
},
"RequestId": "rest-client"
}
}
Output example: failure
{
"Response": {
"Error": {
"Code": "InvalidParameterValue.ErrorUserNotExists",
"Message": "account does not exist"
},
"RequestId": "rest-client"
}
}

5. Error Code

Error Code
Description
InternalError
Internal error.
ErrorRequiredParamNotFound
Required parameter is missing.
InvalidAction
Illegal Action.
InvalidParameterValue
Parameters are abnormal.
InvalidParameterValue.InvalidJSON
The request format is not JSON.
InvalidParameterValue.NickNameLengthInvalid
Nickname length is illegal.