优化OauthApi授权 #64
This commit is contained in:
parent
1aaee7c03d
commit
371b226a9b
@ -11,12 +11,11 @@ import com.foxinmy.weixin4j.model.WeixinAccount;
|
||||
import com.foxinmy.weixin4j.mp.model.OauthToken;
|
||||
import com.foxinmy.weixin4j.mp.model.User;
|
||||
import com.foxinmy.weixin4j.mp.type.Lang;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
* oauth授权
|
||||
*
|
||||
*
|
||||
* @className OauthApi
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年3月6日
|
||||
@ -28,44 +27,70 @@ public class OauthApi extends MpApi {
|
||||
|
||||
private final WeixinAccount account;
|
||||
|
||||
/**
|
||||
* 默认使用weixin4j.properties里面的appid、appsecret信息
|
||||
*/
|
||||
public OauthApi() {
|
||||
this(Weixin4jConfigUtil.getWeixinAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入appid、appsecret信息
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
public OauthApi(WeixinAccount account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
/**
|
||||
* base静默授权:重定向URL使用weixin4j.properties#user.oauth.redirect.uri
|
||||
*
|
||||
* @see {@link #getAuthorizeURL(String, String,String)}
|
||||
*
|
||||
*
|
||||
* @return 请求授权的URL
|
||||
*/
|
||||
public String getAuthorizeURL() {
|
||||
String appId = account.getId();
|
||||
String redirectUri = Weixin4jConfigUtil
|
||||
.getValue("user.oauth.redirect.uri");
|
||||
return getAuthorizeURL(appId, redirectUri, "state", "snsapi_base");
|
||||
return getAuthorizeURL(redirectUri, "state", "snsapi_base");
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求CODE
|
||||
*
|
||||
* @param appId
|
||||
* 应用ID
|
||||
*
|
||||
* @param redirectUri
|
||||
* 重定向地址
|
||||
* 重定向地址<br>
|
||||
* 1、在微信公众号请求用户网页授权之前,开发者需要先到公众平台官网中的开发者中心页配置授权回调域名。请注意,
|
||||
* 这里填写的是域名(是一个字符串),而不是URL,因此请勿加 http:// 等协议头;<br>
|
||||
* 2、授权回调域名配置规范为全域名,比如需要网页授权的域名为
|
||||
* :www.qq.com,配置以后此域名下面的页面http://www.qq.com/music.html 、
|
||||
* http://www.qq.com/login.html<br>
|
||||
* 都可以进行OAuth2.0鉴权。但http://pay.qq.com 、 http://music.qq.com 、
|
||||
* http://qq.com无法进行OAuth2.0鉴权<br>
|
||||
* 3、如果公众号登录授权给了第三方开发者来进行管理,则不必做任何设置,由第三方代替公众号实现网页授权即可
|
||||
* @param state
|
||||
* 用于保持请求和回调的状态,授权请求后原样带回给第三方
|
||||
* @param scope
|
||||
* 应用授权作用域,snsapi_base
|
||||
* (不弹出授权页面,直接跳转,只能获取用户openid),snsapi_userinfo
|
||||
* (弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息)<br>
|
||||
* 1、 以snsapi_base为scope发起的网页授权,是用来获取进入页面的用户的openid的,
|
||||
* 并且是静默授权并自动跳转到回调页的。用户感知的就是直接进入了回调页(往往是业务页面)<br>
|
||||
* 2、以snsapi_userinfo为scope发起的网页授权
|
||||
* ,是用来获取用户的基本信息的。但这种授权需要用户手动同意,并且由于用户同意过
|
||||
* ,所以无须关注,就可在授权后获取该用户的基本信息。<br>
|
||||
* 3、用户管理类接口中的“获取用户基本信息接口”,是在用户和公众号产生消息交互或关注后事件推送后
|
||||
* ,才能根据用户OpenID来获取用户基本信息
|
||||
* ,这个接口,包括其他微信接口,都是需要该用户(即openid)关注了公众号后,才能调用成功的。<br>
|
||||
* @return 请求授权的URL
|
||||
*/
|
||||
public String getAuthorizeURL(String appId, String redirectUri,
|
||||
String state, String... scopes) {
|
||||
public String getAuthorizeURL(String redirectUri, String state, String scope) {
|
||||
String sns_user_auth_uri = getRequestUri("sns_user_auth_uri");
|
||||
try {
|
||||
return String.format(sns_user_auth_uri, appId,
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()),
|
||||
StringUtil.join(scopes, ','), state);
|
||||
return String.format(sns_user_auth_uri, account.getId(),
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), scope,
|
||||
state);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
;
|
||||
}
|
||||
@ -73,61 +98,38 @@ public class OauthApi extends MpApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link #getOauthToken(String, String,String)}
|
||||
*
|
||||
* @return
|
||||
* code换取token
|
||||
*
|
||||
* @param code
|
||||
* 用户同意授权获取的code,
|
||||
* code作为换取access_token的票据,每次用户授权带上的code将不一样,code只能使用一次
|
||||
* ,5分钟未被使用自动过期。
|
||||
* @return oauthtoken信息
|
||||
*/
|
||||
public OauthToken getOauthToken(String code) throws WeixinException {
|
||||
return getOauthToken(code, account.getId(), account.getSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* oauth授权code获取token
|
||||
*
|
||||
* @param code
|
||||
* 用户授权后返回的code
|
||||
* @param appid
|
||||
* 应用ID
|
||||
* @param appsecret
|
||||
* 应用密钥
|
||||
* @return token对象
|
||||
* @throws WeixinException
|
||||
* @see com.foxinmy.weixin4j.mp.model.OauthToken
|
||||
*/
|
||||
public OauthToken getOauthToken(String code, String appid, String appsecret)
|
||||
throws WeixinException {
|
||||
String user_token_uri = getRequestUri("sns_user_token_uri");
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
user_token_uri, appid, appsecret, code));
|
||||
user_token_uri, account.getId(), account.getSecret(), code));
|
||||
|
||||
return response.getAsObject(new TypeReference<OauthToken>() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link #getOauthToken(String, String,String)}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public OauthToken refreshToken(String refreshToken) throws WeixinException {
|
||||
return refreshToken(account.getId(), refreshToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
*
|
||||
* @param appId
|
||||
* 应用ID
|
||||
* 刷新token:由于access_token拥有较短的有效期,当access_token超时后,可以使用refresh_token进行刷新,
|
||||
* refresh_token有效期为30天,当refresh_token失效之后,需要用户重新授权。
|
||||
*
|
||||
*
|
||||
* @param refreshToken
|
||||
* 填写通过access_token获取到的refresh_token参数
|
||||
* @return token对象
|
||||
* @throws WeixinException
|
||||
* {@link #getOauthToken(String)}
|
||||
* @see com.foxinmy.weixin4j.mp.model.OauthToken
|
||||
* @return oauthtoken信息
|
||||
*/
|
||||
public OauthToken refreshToken(String appId, String refreshToken)
|
||||
throws WeixinException {
|
||||
public OauthToken refreshToken(String refreshToken) throws WeixinException {
|
||||
String sns_token_refresh_uri = getRequestUri("sns_token_refresh_uri");
|
||||
WeixinResponse response = weixinExecutor.get(String.format(
|
||||
sns_token_refresh_uri, appId, refreshToken));
|
||||
sns_token_refresh_uri, account.getId(), refreshToken));
|
||||
|
||||
return response.getAsObject(new TypeReference<OauthToken>() {
|
||||
});
|
||||
@ -135,7 +137,7 @@ public class OauthApi extends MpApi {
|
||||
|
||||
/**
|
||||
* 验证access_token是否正确
|
||||
*
|
||||
*
|
||||
* @param oauthToken
|
||||
* 接口调用凭证
|
||||
* @param openId
|
||||
@ -156,7 +158,7 @@ public class OauthApi extends MpApi {
|
||||
|
||||
/**
|
||||
* oauth获取用户信息(需scope为 snsapi_userinfo)
|
||||
*
|
||||
*
|
||||
* @param token
|
||||
* 授权信息(token&openid)
|
||||
* @return 用户对象
|
||||
@ -174,7 +176,7 @@ public class OauthApi extends MpApi {
|
||||
|
||||
/**
|
||||
* oauth获取用户信息(需scope为 snsapi_userinfo)
|
||||
*
|
||||
*
|
||||
* @param oauthToken
|
||||
* 授权票据
|
||||
* @param openid
|
||||
@ -185,6 +187,7 @@ public class OauthApi extends MpApi {
|
||||
* @throws WeixinException
|
||||
* @see <a
|
||||
* href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140842&token=&lang=zh_CN">授权获取用户信息</a>
|
||||
* @see com.foxinmy.weixin4j.mp.model.OauthToken
|
||||
* @see com.foxinmy.weixin4j.mp.model.User
|
||||
*/
|
||||
public User getUser(String oauthToken, String openid, Lang lang)
|
||||
|
||||
@ -23,7 +23,7 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
* 微信第三方应用接口实现
|
||||
*
|
||||
*
|
||||
* @className WeixinSuiteProxy
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月22日
|
||||
@ -37,7 +37,7 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 每个套件授权不一样 suiteId - suiteApi
|
||||
*/
|
||||
*/
|
||||
private Map<String, SuiteApi> suiteMap;
|
||||
/**
|
||||
* 供应商API:如登陆URL
|
||||
@ -53,7 +53,7 @@ public class WeixinSuiteProxy {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param suiteSettings
|
||||
* 套件信息配置
|
||||
*/
|
||||
@ -61,27 +61,32 @@ public class WeixinSuiteProxy {
|
||||
this.suiteSettings = suiteSettings;
|
||||
if (suiteSettings.getWeixinAccount().getSuiteAccounts() != null) {
|
||||
this.suiteMap = new HashMap<String, SuiteApi>();
|
||||
for (WeixinAccount suite : suiteSettings.getWeixinAccount().getSuiteAccounts()) {
|
||||
for (WeixinAccount suite : suiteSettings.getWeixinAccount()
|
||||
.getSuiteAccounts()) {
|
||||
this.suiteMap.put(suite.getId(), new SuiteApi(
|
||||
new SuiteTicketHolder(suite.getId(), suite.getSecret(), suiteSettings.getTokenStorager0())));
|
||||
this.suiteMap.put(null,
|
||||
suiteMap.get(suiteSettings.getWeixinAccount().getSuiteAccounts().get(0).getId()));
|
||||
new SuiteTicketHolder(suite.getId(), suite.getSecret(),
|
||||
suiteSettings.getTokenStorager0())));
|
||||
this.suiteMap.put(
|
||||
null,
|
||||
suiteMap.get(suiteSettings.getWeixinAccount()
|
||||
.getSuiteAccounts().get(0).getId()));
|
||||
}
|
||||
}
|
||||
if (StringUtil.isNotBlank(suiteSettings.getWeixinAccount().getId())
|
||||
&& StringUtil.isNotBlank(suiteSettings.getWeixinAccount().getProviderSecret())) {
|
||||
this.providerApi = new ProviderApi(
|
||||
new TokenHolder(
|
||||
new WeixinProviderTokenCreator(suiteSettings.getWeixinAccount().getId(),
|
||||
suiteSettings.getWeixinAccount().getProviderSecret()),
|
||||
suiteSettings.getTokenStorager0()),
|
||||
&& StringUtil.isNotBlank(suiteSettings.getWeixinAccount()
|
||||
.getProviderSecret())) {
|
||||
this.providerApi = new ProviderApi(new TokenHolder(
|
||||
new WeixinProviderTokenCreator(suiteSettings
|
||||
.getWeixinAccount().getId(), suiteSettings
|
||||
.getWeixinAccount().getProviderSecret()),
|
||||
suiteSettings.getTokenStorager0()),
|
||||
suiteSettings.getTokenStorager0());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业号信息
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WeixinQyAccount getWeixinAccount() {
|
||||
@ -90,7 +95,7 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 获取套件接口对象(只关注第一个套件
|
||||
*
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi
|
||||
* @return API实例
|
||||
*/
|
||||
@ -100,7 +105,7 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 获取套件接口对象(多个套件
|
||||
*
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.qy.api.SuiteApi
|
||||
* @param suiteId
|
||||
* 套件ID
|
||||
@ -112,7 +117,7 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 缓存套件ticket(多个套件
|
||||
*
|
||||
*
|
||||
* @param suiteId
|
||||
* 套件ID
|
||||
* @param suiteTicket
|
||||
@ -122,13 +127,14 @@ public class WeixinSuiteProxy {
|
||||
* 推送suite_ticket协议</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public void cacheTicket(String suiteId, String suiteTicket) throws WeixinException {
|
||||
public void cacheTicket(String suiteId, String suiteTicket)
|
||||
throws WeixinException {
|
||||
suite(suiteId).getTicketHolder().cachingTicket(suiteTicket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用套件授权 <font color="red">需先缓存ticket</font>
|
||||
*
|
||||
*
|
||||
* @see {@link #getSuiteAuthorizeURL(String, String,String)}
|
||||
* @param suiteId
|
||||
* 套件ID
|
||||
@ -137,13 +143,14 @@ public class WeixinSuiteProxy {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String getSuiteAuthorizeURL(String suiteId) throws WeixinException {
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("suite.oauth.redirect.uri");
|
||||
String redirectUri = Weixin4jConfigUtil
|
||||
.getValue("suite.oauth.redirect.uri");
|
||||
return getSuiteAuthorizeURL(suiteId, redirectUri, "state");
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用套件授权 <font color="red">需先缓存ticket</font>
|
||||
*
|
||||
*
|
||||
* @param suiteId
|
||||
* 套件ID
|
||||
* @param redirectUri
|
||||
@ -157,9 +164,11 @@ public class WeixinSuiteProxy {
|
||||
* @return 请求授权的URL
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String getSuiteAuthorizeURL(String suiteId, String redirectUri, String state) throws WeixinException {
|
||||
public String getSuiteAuthorizeURL(String suiteId, String redirectUri,
|
||||
String state) throws WeixinException {
|
||||
try {
|
||||
return String.format(URLConsts.SUITE_OAUTH_URL, suiteId, suite(suiteId).getTicketHolder().getTicket(),
|
||||
return String.format(URLConsts.SUITE_OAUTH_URL, suiteId,
|
||||
suite(suiteId).getTicketHolder().getTicket(),
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
;
|
||||
@ -169,9 +178,10 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 第三方套件获取企业号管理员登录信息
|
||||
*
|
||||
*
|
||||
* @param authCode
|
||||
* oauth2.0授权企业号管理员登录产生的code
|
||||
* oauth2.0授权企业号管理员登录产生的code:通过成员授权获取到的code,每次成员授权带上的code将不一样,
|
||||
* code只能使用一次,5分钟未被使用自动过期
|
||||
* @return 登陆信息
|
||||
* @see com.foxinmy.weixin4j.qy.api.ProviderApi
|
||||
* @see <a href=
|
||||
@ -186,7 +196,7 @@ public class WeixinSuiteProxy {
|
||||
|
||||
/**
|
||||
* 获取登录企业号官网的url
|
||||
*
|
||||
*
|
||||
* @param corpId
|
||||
* <font color="red">oauth授权的corpid</font>
|
||||
* @param targetType
|
||||
@ -200,13 +210,14 @@ public class WeixinSuiteProxy {
|
||||
* 获取登录企业号官网的url</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public String getLoginUrl(String corpId, LoginTargetType targetType, int agentId) throws WeixinException {
|
||||
public String getLoginUrl(String corpId, LoginTargetType targetType,
|
||||
int agentId) throws WeixinException {
|
||||
return providerApi.getLoginUrl(corpId, targetType, agentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建WeixinProxy对象
|
||||
*
|
||||
*
|
||||
* @param suiteId
|
||||
* 套件ID
|
||||
* @param authCorpId
|
||||
@ -215,7 +226,8 @@ public class WeixinSuiteProxy {
|
||||
* @return
|
||||
*/
|
||||
public WeixinProxy getWeixinProxy(String suiteId, String authCorpId) {
|
||||
return new WeixinProxy(suite(suiteId).getPerCodeHolder(authCorpId), suite(suiteId).getSuiteTokenHolder());
|
||||
return new WeixinProxy(suite(suiteId).getPerCodeHolder(authCorpId),
|
||||
suite(suiteId).getSuiteTokenHolder());
|
||||
}
|
||||
|
||||
public final static String VERSION = "1.6.9";
|
||||
|
||||
@ -9,7 +9,7 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
|
||||
/**
|
||||
* 企业号oauth授权
|
||||
*
|
||||
*
|
||||
* @className OauthApi
|
||||
* @author jinyu(foxinmy@gmail.com)
|
||||
* @date 2015年6月11日
|
||||
@ -27,45 +27,54 @@ import com.foxinmy.weixin4j.util.Weixin4jConfigUtil;
|
||||
public class OauthApi extends QyApi {
|
||||
private final WeixinAccount account;
|
||||
|
||||
/**
|
||||
* 默认使用weixin4j.properties里面的corpid、corpsecret信息
|
||||
*/
|
||||
public OauthApi() {
|
||||
this(Weixin4jConfigUtil.getWeixinAccount());
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入corpid、appsecret信息
|
||||
*
|
||||
* @param account
|
||||
*/
|
||||
public OauthApi(WeixinAccount account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业号用户身份授权
|
||||
*
|
||||
* @see {@link #getUserAuthorizeURL(String, String,String)}
|
||||
*
|
||||
* 企业号用户身份授权:重定向URL使用weixin4j.properties#user.oauth.redirect.uri
|
||||
*
|
||||
* @see {@link #getUserAuthorizeURL(String,String)}
|
||||
*
|
||||
* @return 请求授权的URL
|
||||
*/
|
||||
public String getUserAuthorizeURL() {
|
||||
String corpId = account.getId();
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("user.oauth.redirect.uri");
|
||||
return getUserAuthorizeURL(corpId, redirectUri, "state");
|
||||
String redirectUri = Weixin4jConfigUtil
|
||||
.getValue("user.oauth.redirect.uri");
|
||||
return getUserAuthorizeURL(redirectUri, "state");
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业号用户身份授权
|
||||
*
|
||||
* @param corpId
|
||||
* 企业号的corpid
|
||||
*
|
||||
* @param redirectUri
|
||||
* 重定向地址
|
||||
* @param state
|
||||
* 用于保持请求和回调的状态
|
||||
* @return 请求授权的URL
|
||||
* @see UserApi
|
||||
* @see {@link com.foxinmy.weixin4j.qy.WeixinProxy#getUserByCode(String)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%8F%B7%E7%99%BB%E5%BD%95%E6%8E%88%E6%9D%83">
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81">
|
||||
* 企业号用户身份授权</a>
|
||||
*/
|
||||
public String getUserAuthorizeURL(String corpId, String redirectUri, String state) {
|
||||
public String getUserAuthorizeURL(String redirectUri, String state) {
|
||||
String oauth_uri = getRequestUri("user_oauth_uri");
|
||||
try {
|
||||
return String.format(oauth_uri, corpId, URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
return String.format(oauth_uri, account.getId(),
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
;
|
||||
}
|
||||
@ -73,21 +82,21 @@ public class OauthApi extends QyApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业号第三方提供商授权
|
||||
*
|
||||
* @see {@link #getThirdAuthorizeURL(String, String,String)}
|
||||
*
|
||||
* 企业号第三方提供商授权:重定向URL使用weixin4j.properties#third.oauth.redirect.uri
|
||||
*
|
||||
* @see {@link #getThirdAuthorizeURL(String,String)}
|
||||
*
|
||||
* @return 请求授权的URL
|
||||
*/
|
||||
public String getThirdAuthorizeURL() {
|
||||
String corpId = account.getId();
|
||||
String redirectUri = Weixin4jConfigUtil.getValue("third.oauth.redirect.uri");
|
||||
return getThirdAuthorizeURL(corpId, redirectUri, "state");
|
||||
String redirectUri = Weixin4jConfigUtil
|
||||
.getValue("third.oauth.redirect.uri");
|
||||
return getThirdAuthorizeURL(redirectUri, "state");
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业号登陆授权
|
||||
*
|
||||
*
|
||||
* @param corpId
|
||||
* 企业号(提供商)的corpid
|
||||
* @param redirectUri
|
||||
@ -98,13 +107,14 @@ public class OauthApi extends QyApi {
|
||||
* @see ProviderApi
|
||||
* @see {@link com.foxinmy.weixin4j.qy.WeixinSuiteProxy#getOUserInfoByCode(String)}
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E4%BC%81%E4%B8%9A%E5%8F%B7%E7%99%BB%E5%BD%95%E6%8E%88%E6%9D%83">
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%88%90%E5%91%98%E7%99%BB%E5%BD%95%E6%8E%88%E6%9D%83">
|
||||
* 企业号第三方提供商授权</a>
|
||||
*/
|
||||
public String getThirdAuthorizeURL(String corpId, String redirectUri, String state) {
|
||||
public String getThirdAuthorizeURL(String redirectUri, String state) {
|
||||
String oauth_uri = getRequestUri("provider_oauth_uri");
|
||||
try {
|
||||
return String.format(oauth_uri, corpId, URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
return String.format(oauth_uri, account.getId(),
|
||||
URLEncoder.encode(redirectUri, Consts.UTF_8.name()), state);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user