mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-04 06:07:59 +08:00 
			
		
		
		
	Merge pull request #122 from SimonDolph/develop
添加可自定义oauth2 redirectURI的方法
This commit is contained in:
		@ -387,6 +387,18 @@ public interface WxMpService {
 | 
			
		||||
   */
 | 
			
		||||
  public String oauth2buildAuthorizationUrl(String scope, String state);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * <pre>
 | 
			
		||||
   * 构造oauth2授权的url连接
 | 
			
		||||
   * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
 | 
			
		||||
   * </pre>
 | 
			
		||||
   * @param redirectURI
 | 
			
		||||
   *   用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode
 | 
			
		||||
   * @param scope
 | 
			
		||||
   * @param state
 | 
			
		||||
   * @return code
 | 
			
		||||
   */
 | 
			
		||||
  public String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state);
 | 
			
		||||
  /**
 | 
			
		||||
   * <pre>
 | 
			
		||||
   * 用code换取oauth2的access token
 | 
			
		||||
 | 
			
		||||
@ -363,9 +363,14 @@ public class WxMpServiceImpl implements WxMpService {
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public String oauth2buildAuthorizationUrl(String scope, String state) {
 | 
			
		||||
    return this.oauth2buildAuthorizationUrl(wxMpConfigStorage.getOauth2redirectUri(), scope, state);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state) {
 | 
			
		||||
    String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ;
 | 
			
		||||
    url += "appid=" + wxMpConfigStorage.getAppId();
 | 
			
		||||
    url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxMpConfigStorage.getOauth2redirectUri());
 | 
			
		||||
    url += "&redirect_uri=" + URIUtil.encodeURIComponent(redirectURI);
 | 
			
		||||
    url += "&response_type=code";
 | 
			
		||||
    url += "&scope=" + scope;
 | 
			
		||||
    if (state != null) {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user