/**
* 微信网页授权登录
*
* @return 结果
*/
@Anonymous
@GetMapping("/webAuthorize")
public AjaxResult authorize(HttpServletResponse response, HttpSession session, @RequestParam String inviteCode, @RequestParam String uri) throws IOException {
// 生成唯一的 state 值,加入随机数或时间戳
String state = inviteCode + "_STATE_" + UUID.randomUUID().toString();
String scope = "snsapi_userinfo";
String redirectUri = wxMpConfiguration.getRedirectUri();
// 构建授权 URL
String authorizeUrl = wxMpConfiguration.wxMpService()
.getOAuth2Service()
.buildAuthorizationUrl(redirectUri, scope, state) + "&forcePopup=true";
// 清理 session 中的授权状态
session.removeAttribute("authState");
// 返回成功信息并附带授权链接
return AjaxResult.success("授权成功", authorizeUrl);
}
我想做成每次就来都需要重新授权,但是现在的情况是只要第一次授权了,有效期就是30天,能做成每次都需要授权么?
