mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 20:57:47 +08:00
🎨 #2726 【小程序】小程序配置类增加设置自定义的获取accessToken地址
This commit is contained in:
parent
2b93f91af6
commit
918daa2a55
@ -62,10 +62,12 @@ public class WxMaServiceHttpClientImpl extends BaseWxMaServiceImpl {
|
|||||||
@Override
|
@Override
|
||||||
protected String doGetAccessTokenRequest() throws IOException {
|
protected String doGetAccessTokenRequest() throws IOException {
|
||||||
|
|
||||||
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
|
||||||
|
this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL;
|
WxMaService.GET_ACCESS_TOKEN_URL;
|
||||||
|
|
||||||
|
|
||||||
url = String.format(url, this.getWxMaConfig().getAppid(), this.getWxMaConfig().getSecret());
|
url = String.format(url, this.getWxMaConfig().getAppid(), this.getWxMaConfig().getSecret());
|
||||||
|
|
||||||
HttpGet httpGet = null;
|
HttpGet httpGet = null;
|
||||||
|
@ -46,7 +46,8 @@ public class WxMaServiceJoddHttpImpl extends BaseWxMaServiceImpl<HttpConnectionP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doGetAccessTokenRequest() throws IOException {
|
protected String doGetAccessTokenRequest() throws IOException {
|
||||||
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
|
||||||
|
this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL;
|
WxMaService.GET_ACCESS_TOKEN_URL;
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ public class WxMaServiceOkHttpImpl extends BaseWxMaServiceImpl<OkHttpClient, OkH
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doGetAccessTokenRequest() throws IOException {
|
protected String doGetAccessTokenRequest() throws IOException {
|
||||||
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
String url = StringUtils.isNotEmpty(this.getWxMaConfig().getAccessTokenUrl()) ?
|
||||||
|
this.getWxMaConfig().getAccessTokenUrl() : StringUtils.isNotEmpty(this.getWxMaConfig().getApiHostUrl()) ?
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
WxMaService.GET_ACCESS_TOKEN_URL.replace("https://api.weixin.qq.com", this.getWxMaConfig().getApiHostUrl()) :
|
||||||
WxMaService.GET_ACCESS_TOKEN_URL;
|
WxMaService.GET_ACCESS_TOKEN_URL;
|
||||||
|
|
||||||
|
@ -250,4 +250,19 @@ public interface WxMaConfig {
|
|||||||
* @return 自定义的api域名地址
|
* @return 自定义的api域名地址
|
||||||
*/
|
*/
|
||||||
String getApiHostUrl();
|
String getApiHostUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取自定义的获取accessToken地址,用于向自定义统一服务获取accessToken
|
||||||
|
*
|
||||||
|
* @return 自定义的获取accessToken地址
|
||||||
|
*/
|
||||||
|
String getAccessTokenUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置自定义的获取accessToken地址
|
||||||
|
* 可用于设置获取accessToken的自定义服务
|
||||||
|
*
|
||||||
|
* @param accessTokenUrl 自定义的获取accessToken地址
|
||||||
|
*/
|
||||||
|
void setAccessTokenUrl(String accessTokenUrl);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ public class WxMaDefaultConfigImpl implements WxMaConfig {
|
|||||||
protected volatile Lock cardApiTicketLock = new ReentrantLock();
|
protected volatile Lock cardApiTicketLock = new ReentrantLock();
|
||||||
private volatile ApacheHttpClientBuilder apacheHttpClientBuilder;
|
private volatile ApacheHttpClientBuilder apacheHttpClientBuilder;
|
||||||
private String apiHostUrl;
|
private String apiHostUrl;
|
||||||
|
private String accessTokenUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会过期的数据提前过期时间,默认预留200秒的时间
|
* 会过期的数据提前过期时间,默认预留200秒的时间
|
||||||
@ -303,6 +304,11 @@ public class WxMaDefaultConfigImpl implements WxMaConfig {
|
|||||||
this.apiHostUrl = apiHostUrl;
|
this.apiHostUrl = apiHostUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAccessTokenUrl(String accessTokenUrl) {
|
||||||
|
this.accessTokenUrl = accessTokenUrl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAppid() {
|
public String getAppid() {
|
||||||
return appid;
|
return appid;
|
||||||
|
@ -257,6 +257,7 @@ public class WxOpenInMemoryConfigStorage implements WxOpenConfigStorage {
|
|||||||
private final String appId;
|
private final String appId;
|
||||||
private WxMpHostConfig hostConfig;
|
private WxMpHostConfig hostConfig;
|
||||||
private String apiHostUrl;
|
private String apiHostUrl;
|
||||||
|
private String accessTokenUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小程序原始ID
|
* 小程序原始ID
|
||||||
|
Loading…
Reference in New Issue
Block a user