回调方法:
//扫描二维码授权成功,取到code,回调方法
@RequestMapping(value = "/pcAuth")
@ResponseBody
public String pcCallback(String code,String state,HttpServletRequest request,HttpServletResponse response) throws Exception {
String result = weChatAuthService.getAccessToken(code);
JSONObject jsonObject = JSONObject.parseObject(result);
//String refresh_token = jsonObject.getString("refresh_token");
String access_token = jsonObject.getString("access_token");
String openId = jsonObject.getString("openId");
System.out.println("state:"+state+"\n code:"+code+"\n openId:"+openId);
logger.info("------------授权成功----------------");
JSONObject infoJson = weChatAuthService.getUserInfo(access_token,openId);
if(infoJson!=null){
System.out.println("1");
String nickname = infoJson.getString("nickName");
logger.info("-----nickname-----"+nickname);
logger.info("-----sessionId-----"+state);
infoJson.put("openId", openId);
redisTemplate.setValueSerializer(new EntityRedisSerializer());
redisTemplate.opsForValue().set(state, infoJson, 10*60, TimeUnit.SECONDS);
System.out.println("getState:"+redisTemplate.opsForValue().get(state+""));
return "登录成功!";
}
return "登录失败!";
}
用手机扫码后,手机授权后页面显示“登陆成功!”
这个回调方法是不是手机端调用的啊?
如果我想手机端登陆后直接回到微信列表页,怎么做??求大佬告知???