2019-08-10 14:06
String redirectUri = PropKit.get("domain")+ "/mp/auth/login?url=" + url;
return SnsAccessTokenApi.getAuthorizeURL(appId, redirectUri, state, false);
这是我构建微信授权的URL,,url是当前action的url,你在授权后的login中获取code,获取用户信息,然后在redirect(url)
public void login() {
String code = get("code");
String url = get("url");
WechatUser user = service.loginByAuthCode(code);
if(user != null) {
setSessionAttr(SessionKey.WECHAT_USER_ID, user);
redirect(url);
} else {
renderText("授权失败");
}
}