@@ -42,12 +42,11 @@ public String authorize(@RequestParam("returnUrl") String returnUrl){
42
42
String url =projectUrlConfig .getWechatMpAuthorize ()+"/sell/wechat/userInfo" ;
43
43
String redirectUrl =wxMpService .oauth2buildAuthorizationUrl (url ,WxConsts .OAUTH2_SCOPE_BASE , URLEncoder .encode (returnUrl ));
44
44
log .info ("【微信网页授权】获取code,redirectUrl={}" ,redirectUrl );
45
- return "redirect:" +redirectUrl ;
45
+ return "redirect:" +redirectUrl ;//重定向到下面一个方法
46
46
}
47
47
@ GetMapping ("/userInfo" )
48
48
public String userInfo (@ RequestParam ("code" ) String code ,
49
49
@ RequestParam ("state" ) String returnUrl ){
50
- log .info ("hello" );
51
50
WxMpOAuth2AccessToken wxMpOAuth2AccessToken =new WxMpOAuth2AccessToken ();
52
51
try {
53
52
wxMpOAuth2AccessToken =wxMpService .oauth2getAccessToken (code );
@@ -59,8 +58,11 @@ public String userInfo(@RequestParam("code") String code,
59
58
log .info ("【微信网页授权】获取openid,returnUrl={}" ,returnUrl );
60
59
return "redirect:" + returnUrl +"?openid=" +openId ;
61
60
62
- }
61
+ }//以上两个方法是SDK方式微信网页授权的过程,
62
+ // 访问http://sqmax.natapp1.cc/sell/wechat/authorize?returnUrl=http://www.imooc.com,
63
+ //最终将会跳转到这个链接:http://www.imooc.com?openid={openid}
63
64
65
+ //微信登陆
64
66
@ GetMapping ("/qrAuthorize" )
65
67
public String qrAuthorize (@ RequestParam ("returnUrl" ) String returnUrl ){
66
68
String url =projectUrlConfig .getWechatOpenAuthorize ()+"/sell/wechat/userInfo" ;
0 commit comments