mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-01 00:46:54 +08:00 
			
		
		
		
	🆕 #2207 【企业微信】增加构建扫码登录二维码链接的方法
This commit is contained in:
		| @@ -287,6 +287,14 @@ public interface WxCpService extends WxService { | ||||
|    */ | ||||
|   void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider); | ||||
|  | ||||
|   /** | ||||
|    * 构造扫码登录链接 - 构造独立窗口登录二维码 | ||||
|    * @param redirectUri 重定向地址,需要进行UrlEncode | ||||
|    * @param state 用于保持请求和回调的状态,授权请求后原样带回给企业。该参数可用于防止csrf攻击(跨站请求伪造攻击),建议企业带上该参数,可设置为简单的随机数加session进行校验 | ||||
|    * @return . | ||||
|    */ | ||||
|   String buildQrConnectUrl(String redirectUri, String state); | ||||
|  | ||||
|   /** | ||||
|    * 获取部门相关接口的服务类对象 | ||||
|    * | ||||
|   | ||||
| @@ -17,15 +17,13 @@ import me.chanjar.weixin.common.session.WxSessionManager; | ||||
| import me.chanjar.weixin.common.util.DataUtils; | ||||
| import me.chanjar.weixin.common.util.RandomUtils; | ||||
| import me.chanjar.weixin.common.util.crypto.SHA1; | ||||
| import me.chanjar.weixin.common.util.http.RequestExecutor; | ||||
| import me.chanjar.weixin.common.util.http.RequestHttp; | ||||
| import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor; | ||||
| import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor; | ||||
| import me.chanjar.weixin.common.util.http.*; | ||||
| import me.chanjar.weixin.common.util.json.GsonParser; | ||||
| import me.chanjar.weixin.cp.api.*; | ||||
| import me.chanjar.weixin.cp.bean.WxCpMaJsCode2SessionResult; | ||||
| import me.chanjar.weixin.cp.bean.WxCpProviderToken; | ||||
| import me.chanjar.weixin.cp.config.WxCpConfigStorage; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.IOException; | ||||
| @@ -394,6 +392,13 @@ public abstract class BaseWxCpServiceImpl<H, P> implements WxCpService, RequestH | ||||
|     return get(url, null); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String buildQrConnectUrl(String redirectUri, String state) { | ||||
|     return String.format("https://open.work.weixin.qq.com/wwopen/sso/qrConnect?appid=%s&agentid=%s&redirect_uri=%s&state=%s", | ||||
|       this.configStorage.getCorpId(), this.configStorage.getAgentId(), | ||||
|       URIUtil.encodeURIComponent(redirectUri), StringUtils.trimToEmpty(state)); | ||||
|   } | ||||
|  | ||||
|   public File getTmpDirFile() { | ||||
|     return this.tmpDirFile; | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang