# Refresh user authorization credentials

Debugging Tools

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 English name: snsRefreshToken

Because access_token has a short expiration date, when the access_token is overdue, it can be refreshed using the refresh_token, which is valid for 30 days, and when the refresh-token expires, the user is required to reauthorize.

Note: The frequency limit for this interface is 50,000 / min

# 1. How to call

# HTTPS calls

GET https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=GRANT_TYPE&refresh_token=REFRESH_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

Parameter NametypeRequired to fill inExampleIntroductions
appidstringyes-Unique identifier for Official Account
grant_typestringyesrefresh_tokenFill in refresh_token
refresh_tokenstringyes-Fill in the refresh_token parameter obtained by access_token

# Request BodyRequest Payload

nothing

# 3. Return Parameters

# Response Payload

Parameter NametypeIntroductions
access_tokenstringWeb page authorization interface invocation credentials. Note: This access_token is different from the underlying supported access_token
expires_innumberaccess_token Interface Call Credential Timeout, in seconds
refresh_tokenstringUser refresh access_token
openidstringUser unique identifier
scopestringUser authorized domains, separated by comma (,)

# 4. Note

There are no special considerations for this interface

# 5. Code examples

Example Requests

https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN

Return an example

{ 
  "access_token":"ACCESS_TOKEN",
  "expires_in":7200,
  "refresh_token":"REFRESH_TOKEN",
  "openid":"OPENID",
  "scope":"SCOPE" 
}

# 6. Error code

The following is a list of error codes for this interface, other error codes can refer to General error codes

Error codeError DescriptionSolutions
40029Invalid codeJs_code is invalid

# 7. Scope of application

How this interface can be invoked under different account types:
Service Account Mobile App Website App
Certification only
  • Authentication only: means that only authenticated accounts are allowed to be invoked by the enterprise entity, and accounts that are not authenticated or do not support authentication cannot be invoked.
  • ✔: The account can call this interface
  • Other account types that are not expressly stated may not be called on this interface without special instructions;