Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wechat : OAuth with test account

I'm actually trying to set up a OAuth login with WeChat for my web application. So, I have create a account on wechat, and I used a Test account to have all access unlimited.

So, on the test account configuration, I have successfully validate the token from wechat (see here : http://admin.wechat.com/wiki/index.php?title=Getting_Started).

On the doc, OAuth is explain here : http://admin.wechat.com/wiki/index.php?title=User_Profile_via_Web

We must redirect user to this URL for login: https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect

I have replace APPID by my test account AppId, my redirect URI like : http://wechat.mydomain.net, SCOPE by the correct one (snsapi_userinfo) and remove the state param (optional). But, I had a error on Wechat :

Oops! Something went wrong:(

After hours of research, I set the domain on "Api permission list", in " Webpage Account" Wechat configuration

But I always have this error. Maybe I missing something, but I don't find what. There is my final URL called : https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8ytvf5838cc7t33d&redirect_uri=http://wechat.mydomain.net/wechat/callback&response_type=code&scope=snsapi_userinfo&connect_redirect=1#wechat_redirect

Thanks for your help !

like image 928
PallMallShow Avatar asked Mar 13 '23 13:03

PallMallShow


1 Answers

Hope it still relevant for you (or anyone else)

The WeChat oAuth seems to be only available from an Official account and not supported in the Test account.

If you have an approved official account, you can check it under the permissions tab in the admin.

Anyway - the login callback will always return an error if not called from the WeChat native application. You can not just open it in the browser.

You can check my PHP class at GitHub, it includes (for now) the oAuth and the messages engine: https://github.com/nitzanb/wechat-class

like image 178
TwoDiv Avatar answered Mar 30 '23 04:03

TwoDiv