An error message appears when Android calls WeChat login: {"errcode":40029,"errmsg":"invalid code"}

When developing an Android application for WeChat login, the Android application initiates a WeChat authorization login request. After the WeChat user allows the authorization of the Android application, WeChat will launch the application or redirect to a third-party website with the code parameter of the authorization temporary ticket;

 

But found that https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code returns such an error message returns {"errcode":40029,"errmsg":"invalid code, hints: [ req_id: xxxx]"}
 


 

Looking at the relevant information, it is said that because this code has been used, if you need to call the user information again, you will need to obtain it again.
It turns out that the default timeout time of Android is 3 seconds. When it exceeds 3 seconds, the request will be re-initiated. This leads to the reason why the code is invalid.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326764084&siteId=291194637