May 19, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
Gets the credentials (or information) of the program's globally unique access_token. The vast majority of background interfaces need to be called using access_token, and developers need to keep them properly.
GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
Property | Type | The default | Required | Description |
---|---|---|---|---|
grant_type | string | Is | Fill in client_credential | |
appid | string | Is | The unique credentials of the applet, the AppID, are available on the WeChat Public Platform - Settings - Development Settings page. (Need to have become a developer, and the account has no abnormal status) | |
secret | string | Is | The program's unique credential key, AppSecret, is obtained in the same way as the appid |
The returned JSON packet
Property | Type | Description |
---|---|---|
access_token | string | The credentials obtained |
expires_in | number | Voucher valid time, in seconds. It is currently a value of 7200 seconds. |
errcode | number | Error code |
errmsg | string | Error message |
Errcode's legitimate value
value | illustrate | Minimum version |
---|---|---|
-1 | The system is busy, please developers will try again later. | |
0 | Request success | |
40001 | Appsecret error or AppSecret does not belong to this applet, ask the developer to confirm the correctness of AppSecret | |
40002 | Make sure the GRANT_TYPE field value is Client_credential | |
40013 | If you are not legal, please ask the developer to check the correctness of the AppID, avoid exception character, pay attention to the case |
Normal return
{"access_token":"ACCESS_TOKEN","expires_in":7200}
Return when the error is wrong
{"errcode":40013,"errmsg":"invalid appid"}