# Get stable version interface call credentials
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface name: getStableAccessToken
- Obtain the global background interface call credentials, valid for up to 7200s, developers need to properly save;
- There are two invocation modes: 1. Normal mode,
access_token
Repeated invocation of the interface within the validity period does not updateaccess_token
, which is used in most scenarios;2.Force refresh mode, which causes the last access_tokenaccess_token
to be invalidated and returns a newaccess_token
; - The interface is limited to 10, 000 calls per minute and 500 thousand calls per day.
- Completely isolated from the invocation credentials obtained by getAccessToken .This interface only supports calls in the form of
POST JSON
; - If you use the cloud to develop , you can call](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html) through the [cloud without maintenance;
- Such as using cloud hosting can also be called by WeChat token / open interface to service without maintenance;
# 1. How to call
# HTTPS calls
POST https://api.weixin.qq.com/cgi-bin/stable_token
# Cloud Calls
- This interface does not support cloud calls
# Third party invocation
- Third Party Platform calls are not supported by this interface.
# 2. Request parameters
# Query parametersQuery String parameters
nothing
# Request BodyRequest Payload
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
grant_type | string | yes | Fill in client_credential |
appid | string | yes | The account's unique credentials, that is, AppID, click here to see How to get Appid |
secret | string | yes | Unique credential key, AppSecret, click here to see How to get AppSecret |
force_refresh | boolean | no | False is used by default. 1.When force_refresh = false, it is called in normal mode, access_token repeatedly calling the interface within the validity period does not update access_token;2.Forced refresh mode when force_refresh = true, invalidates the last access_token acquired and returns a new access_token |
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
access_token | string | Credentials obtained |
expires_in | number | Credential validity time, in units: seconds. The current value is within 7,200 seconds. |
# 4. Note
- The frequency of the interface calls is limited to 10,000 times per minute and 50w times per day.It is completely isolated from the credentials of that get the interface call credentials .
- This interface only supports calls in the form of POST JSON;
- "access_token storage space is reserved for at least 512 characters,"
- "The mandatory refresh mode is limited to 20 times per day at intervals of 30 seconds,"
- "In normal mode, the platform is updated 5 minutes earlier access_token"
# 5. Code examples
# 5.1 Does not force refresh to get the token (force_refresh is not passed, default is false)
Example Requests
POST https://api.weixin.qq.com/cgi-bin/stable_token
{
"grant_type": "client_credential",
"appid": "APPID",
"secret": "APPSECRET"
}
Return an example
{
"access_token":"ACCESS_TOKEN",
"expires_in":7200
}
# 5.2 Do not force refresh to get the token (set force_refresh to false):
Example Requests
{
"grant_type": "client_credential",
"appid": "APPID",
"secret": "APPSECRET",
"force_refresh": false
}
Return an example
{
"access_token":"ACCESS_TOKEN",
"expires_in":345 // 如果仍然有效,会返回上次的 token,并给出所剩有效时间
}
# 5.3 Mandatory refresh mode, use with caution, continuous use requires at least 30 s interval
Example Requests
POST https://api.weixin.qq.com/cgi-bin/stable_token
{
"grant_type": "client_credential",
"appid": "APPID",
"secret": "APPSECRET",
"force_refresh": true
}
Return an example
{
"access_token":"ACCESS_TOKEN",
"expires_in":7200
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
-1 | system error | The system is busy, so the developer is asked to try again in a few minutes. |
0 | ok | ok |
40002 | invalid grant_type | Types of Unlawful Credentials |
40013 | invalid appid | Invalid AppID, please check the correctness of the AppID, avoid abnormal characters, pay attention to the case |
40125 | invalid appsecret | Invalid appsecret, please check the correctness of appsecret |
40164 | invalid ip not in whitelist | Add ip to the ip whitelisting list |
41002 | appid missing | Missing AppID parameter |
41004 | appsecret missing | Missing secret parameter |
43002 | require POST method | Need POST Request |
45009 | reach max api daily quota limit | Calls exceed the day-level frequency limit. The clear_quota interface can be called to restore the call quota. |
45011 | api minute-quota reach limit mustslower retry next minute | API calls are too frequent, please try again later |
89503 | This call requires administrator confirmation. Please be patient. | undefined |
89506 | This IP call request has been rejected by Official Account administrator. Please try again after 24 hours. It is recommended to confirm with administrator before calling | undefined |
89507 | This IP call request has been rejected by Official Account administrator. Please try again after 1 hour. It is recommended to confirm with administrator before calling. | undefined |
# 7. Scope of application
How this interface can be invoked under different account types:
Weixin Mini Program | Official Account | Service Account | MiniGame | Weixin Store | Alliance Shipping Agency | Delivery Assistant | Mobile App | Website App | Weixin Channels Assistant | Multi-platform App |
---|---|---|---|---|---|---|---|---|---|---|
✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
- ✔: The account can call this interface
- Other account types that are not expressly stated may not be called on this interface without special instructions;