微信授权 ip全是腾讯云 最近又出现用户回调code无效的问题
@Override
@Transactional(rollbackFor = Exception.class)
public void callBack(HttpServletRequest request, HttpServletResponse response) throws IOException {
GetUserInfoUtils getUserInfoUtils = new GetUserInfoUtils();
Map<String, String> userInfo = getUserInfoUtils.getUserInfo(request);
userInfo.forEach((k, v) -> log.info("key:{},value:{}", k, v));
String ipAddress = userInfo.get("ipAddress");
String redirectUrl = "";
String redirect_uri = URLEncoder.encode(urls, "UTF-8");
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?"
+ "appid=" + appid
+ "&redirect_uri=" + redirect_uri
+ "&response_type=code"
+ "&scope=snsapi_base"
+ "&state=" + System.currentTimeMillis()
+ "&connect_redirect=1#wechat_redirect";
// + "#wechat_redirect";
log.info("url {}",url);
return url;
log.info("code {}", code);
try {
String url = "https://api.weixin.qq.com/sns/oauth2/access_token?"
+ "appid=" + appId
+ "&secret=" + secret
+ "&code=" + code
+ "&grant_type=authorization_code";
JSONObject jsonObject = JSON.parseObject(HttpUtil.get(url));
Integer errcode = jsonObject.getInteger("errcode");
if (errcode != null && errcode == 40029){
return null;
}
要么code没有 要么无效
01:39:21.734 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:deviceType,value:Mobile
01:39:21.735 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:ipAddress,value:49.234.27.58
01:39:21.735 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:userAgent,value:Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36
01:39:21.735 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:operatingSystem,value:Android
01:39:21.737 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [callBack,300] - 回调过来的state 1720265793217
01:39:21.738 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [callBack,301] - 当前时间戳currentTimeMillis 1720287561737
01:39:21.738 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [callBack,302] - 回调过来的loginType 1
01:39:21.738 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [callBack,303] - 回调过来的machineId 143679213
01:39:21.738 [http-nio-8888-exec-63] INFO y.w.s.I.WxServiceImpl - [callBack,307] - 是否在五分钟之内 false
01:39:22.167 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:deviceType,value:Mobile
01:39:22.168 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:ipAddress,value:106.55.202.193
01:39:22.168 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:userAgent,value:Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Mobile Safari/537.36
01:39:22.168 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:operatingSystem,value:Android
01:39:22.171 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [callBack,300] - 回调过来的state 1720263724615
01:39:22.171 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [callBack,301] - 当前时间戳currentTimeMillis 1720287562171
01:39:22.171 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [callBack,302] - 回调过来的loginType 1
01:39:22.171 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [callBack,303] - 回调过来的machineId 142436503
01:39:22.171 [http-nio-8888-exec-84] INFO y.w.s.I.WxServiceImpl - [callBack,307] - 是否在五分钟之内 false
01:39:46.381 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:deviceType,value:Desktop
01:39:46.381 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:ipAddress,value:106.55.200.233
01:39:46.381 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:userAgent,value:Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
01:39:46.381 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [lambda$callBack$0,274] - key:operatingSystem,value:Android
01:39:46.384 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [callBack,300] - 回调过来的state 1720264875829
01:39:46.384 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [callBack,301] - 当前时间戳currentTimeMillis 1720287586384
01:39:46.385 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [callBack,302] - 回调过来的loginType 1
01:39:46.385 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [callBack,303] - 回调过来的machineId 142274811
01:39:46.385 [http-nio-8888-exec-16] INFO y.w.s.I.WxServiceImpl - [callBack,307] - 是否在五分钟之内 false
请求大佬帮忙解决!