WeChat SendAuth request for access token code only works once

847 views Asked by At

I am following the WeChat Login documentation for Android and it works but only once and I can't repeat the process.

I use this code to get the access token code:

IWXAPI api = WXAPIFactory.createWXAPI(this, APP_ID, false);
SendAuth.Req request = new SendAuth.Req();
request.scope = "snsapi_userinfo";
request.state = "wechat_sdk_demo_test";
api.sendReq(request);

I have created the WXEntryActivty and I received the response from the WeChat app and I can finish the login process.

But if I reinstall my app and try to login with WeChat again I always get ERR_BAN (-6) error code. To make it work again I have to reinstall the WeChat app.

I could't find anything about when can I get ERR_BAN error code in the documentation. Can anyone help me with this problem?

2

There are 2 answers

2
csabapap On BEST ANSWER

I managed to solve the problem. I copied the MD5 signature directly from the keytool's output which is contains colons :. I removed the colons from the signature and now it works correctly.

I think this is a bug in the WeChat app because the signature works with colons when the app displays the authorization page but not after that.

0
hiperboreo On

I had many problems using Wechat API and testing directly on wechat app on my phone due to CACHE. It's very difficult to flush wechat cache, i would say almost impossible, that's why you have to re install wechat to start your tests again. I highly suggest you to use the desktop testing app for wechat, download it here, links are in the end of the page: https://mp.weixin.qq.com/wiki?action=doc&id=mp1455784140

Then you will be able to debug every step of your development AND flush cache. Additionally you can link the software to your phone and debug what happens inside wechat web browser.