🐛 微信授权后跳转返回界面失败问题修复
This commit is contained in:
parent
6b67f4c6b0
commit
15bef06adb
@ -8,7 +8,6 @@ import me.chanjar.weixin.common.util.http.URIUtil;
|
|||||||
import me.chanjar.weixin.mp.api.WxMpService;
|
import me.chanjar.weixin.mp.api.WxMpService;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -28,16 +27,22 @@ public class WxoAuthController {
|
|||||||
@Value("${resource.domain}")
|
@Value("${resource.domain}")
|
||||||
private String domain;
|
private String domain;
|
||||||
|
|
||||||
|
@Value("${server.servlet.context-path}")
|
||||||
|
private String contextPath;
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String wxAuth(@PathVariable String appId, @RequestParam(name = "redirectUrl") String redirectUrl) {
|
public String wxAuth(@PathVariable String appId, @RequestParam(name = "redirectUrl") String redirectUrl) {
|
||||||
|
StringBuilder baseUrl;
|
||||||
wxMpService.switchoverTo(appId);
|
wxMpService.switchoverTo(appId);
|
||||||
|
// 测试号
|
||||||
if ("wxa49093339a5a822b".equals(appId)) {
|
if ("wxa49093339a5a822b".equals(appId)) {
|
||||||
domain = "http://oae.nat300.top/vertical";
|
baseUrl = new StringBuilder("http://1wx.rymcu.com").append(contextPath);
|
||||||
} else {
|
} else {
|
||||||
domain += "/vertical-console";
|
baseUrl = new StringBuilder(domain).append(contextPath);
|
||||||
}
|
}
|
||||||
StringBuilder accessTokenUrl = new StringBuilder(domain).append("/wx/oauth/" + appId + "/getAccessToken?redirectUrl=").append(URIUtil.encodeURIComponent(domain + redirectUrl));
|
StringBuilder accessTokenUrl = baseUrl.append("/wx/oauth/" + appId + "/getAccessToken?redirectUrl=").append(URIUtil.encodeURIComponent(redirectUrl));
|
||||||
String oauth2Url = wxMpService.oauth2buildAuthorizationUrl(accessTokenUrl.toString(), WxConsts.OAuth2Scope.SNSAPI_BASE, null);
|
String oauth2Url = wxMpService.oauth2buildAuthorizationUrl(accessTokenUrl.toString(), WxConsts.OAuth2Scope.SNSAPI_BASE, null);
|
||||||
|
|
||||||
return "redirect:" + oauth2Url;
|
return "redirect:" + oauth2Url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user