# getAccessToken

Get multi-end background interface call credentials, token valid for 7200s, developers need to be properly saved.

# Invocation mode

GET https://api.weixin.qq.com/cgi-bin/Token

# Request parameters

attribute type Introductions
grant_type string Type of authorization: client_credential
appid string Multiterminal application ID
secret string Multiterminal application key
{
  grant_type: 'client' _credential',
  Apps:  'aaa', 
  secret: 'bbb' 
}

# Return parameter

attribute type Introductions
access_Token string The certificate obtained
expires_in number Certificate valid time, unit: seconds. The current value is within 7200 seconds.
{
  "access_token":"ACCESS_TOKEN",
  "expires_in":7200
}

# Error code

Error code Error code value Solutions
-1 system error The system is busy, please try again later.
40001 invalid credential access_Token isinvalid or not latest Obtain access_Token time AppSecret Error, or access_Token Invalid. Ask the developer to be more careful AppSecret Or to see if the interface is being invoked for the appropriate multiterminal application
40013 invalid appid Illegal AppID , Please Developer Check AppID Of the correctness, avoid abnormal characters, pay attention to the case

# Other Notes

# access_Token Storage and update of

  • access_Token The storage should be retained at least 512 Character space
  • access_Token The period of validity is currently 2 Hours, need to be refreshed regularly, repeated acquisition will cause the last acquired access_Token Invalid
  • It is recommended that developers use the in-control server to uniformly acquire and refresh access_Token used by other business logic servers access_Token Are from the central control server, should not be refreshed, otherwise it is easy to cause conflicts, resulting in access_Token Coverage Affects Business
  • access_Token Of the validity of the return of the expires_in To convey that the current value is within 7200 seconds, the central control server needs to refresh in advance according to this effective time. In the refresh process, the central control server can continue to output the old access_Token, at this time the multi-end background will ensure that in 5 minutes, new and old access_Token Are available, which guarantees a smooth transition of third party business
  • access_Token The effective time may be adjusted in the future, so the central control server not only needs internal timing active refresh, but also needs to provide passive refresh. access_Token This makes it easy for the business server to learn about the API call access_Token Has timed out, you can trigger the access_Token Of the refresh process.

For details, please refer to the WeChat Official Platform document Getting access_token》