@@ -353,10 +353,11 @@ public interface WxCpService { | |||||
* 构造oauth2授权的url连接 | * 构造oauth2授权的url连接 | ||||
* 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code | * 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code | ||||
* </pre> | * </pre> | ||||
* @param redirectUri | |||||
* @param state | * @param state | ||||
* @return code | * @return code | ||||
*/ | */ | ||||
String oauth2buildAuthorizationUrl(String state); | |||||
String oauth2buildAuthorizationUrl(String redirectUri, String state); | |||||
/** | /** | ||||
* <pre> | * <pre> | ||||
@@ -412,10 +412,10 @@ public class WxCpServiceImpl implements WxCpService { | |||||
} | } | ||||
@Override | @Override | ||||
public String oauth2buildAuthorizationUrl(String state) { | |||||
public String oauth2buildAuthorizationUrl(String redirectUri, String state) { | |||||
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ; | String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ; | ||||
url += "appid=" + wxCpConfigStorage.getCorpId(); | url += "appid=" + wxCpConfigStorage.getCorpId(); | ||||
url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxCpConfigStorage.getOauth2redirectUri()); | |||||
url += "&redirect_uri=" + URIUtil.encodeURIComponent(redirectUri); | |||||
url += "&response_type=code"; | url += "&response_type=code"; | ||||
url += "&scope=snsapi_base"; | url += "&scope=snsapi_base"; | ||||
if (state != null) { | if (state != null) { | ||||
@@ -62,7 +62,7 @@ public class WxCpDemoServer { | |||||
@Override | @Override | ||||
public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, | public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, | ||||
WxCpService wxCpService, WxSessionManager sessionManager) { | WxCpService wxCpService, WxSessionManager sessionManager) { | ||||
String href = "<a href=\"" + wxCpService.oauth2buildAuthorizationUrl(null) | |||||
String href = "<a href=\"" + wxCpService.oauth2buildAuthorizationUrl(wxCpConfigStorage.getOauth2redirectUri(), null) | |||||
+ "\">测试oauth2</a>"; | + "\">测试oauth2</a>"; | ||||
return WxCpXmlOutMessage | return WxCpXmlOutMessage | ||||
.TEXT() | .TEXT() | ||||