今天偶然发现,微信公众号自定义网页授权第一次授权的时候跳转了2次。
第一次获取到openid后方法还没走完,紧着第二次请求到了。
报如下错误
{"errcode":40163,"errmsg":"code been used, hints: [ req_id: _01742031 ]"}
解决办法:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxxxxx&redirect_uri=http%3A%2F%2Fxxx.com%2Fsyb-wx%xxx%2Fxxx.jhtml&response_type=code&scope=snsapi_base&state=xhZzCN&connect_redirect=1#wechat_redirect
授权url加上 &connect_redirect=1