mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
issue #39 公众号添加oauth2的支持
This commit is contained in:
@@ -25,7 +25,7 @@ public interface WxMpConfigStorage {
|
||||
|
||||
public int getExpiresIn();
|
||||
|
||||
public String getOauth2redirectUrl();
|
||||
public String getOauth2redirectUri();
|
||||
|
||||
public String getHttp_proxy_host();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
|
||||
protected int http_proxy_port;
|
||||
protected String http_proxy_username;
|
||||
protected String http_proxy_password;
|
||||
protected String oauth2redirectUrl;
|
||||
protected String oauth2redirectUri;
|
||||
|
||||
public void updateAccessToken(WxAccessToken accessToken) {
|
||||
updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
|
||||
@@ -80,12 +80,12 @@ public class WxMpInMemoryConfigStorage implements WxMpConfigStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOauth2redirectUrl() {
|
||||
return this.oauth2redirectUrl;
|
||||
public String getOauth2redirectUri() {
|
||||
return this.oauth2redirectUri;
|
||||
}
|
||||
|
||||
public void setOauth2redirectUrl(String oauth2redirectUrl) {
|
||||
this.oauth2redirectUrl = oauth2redirectUrl;
|
||||
public void setOauth2redirectUri(String oauth2redirectUri) {
|
||||
this.oauth2redirectUri = oauth2redirectUri;
|
||||
}
|
||||
|
||||
public String getHttp_proxy_host() {
|
||||
|
||||
@@ -27,13 +27,11 @@ import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.utils.URIUtils;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.BasicResponseHandler;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
|
||||
import javax.print.DocFlavor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -303,7 +301,7 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
public String oauth2buildAuthorizationUrl(String scope, String state) {
|
||||
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ;
|
||||
url += "appid=" + wxMpConfigStorage.getAppId();
|
||||
url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxMpConfigStorage.getOauth2redirectUrl());
|
||||
url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxMpConfigStorage.getOauth2redirectUri());
|
||||
url += "&response_type=code";
|
||||
url += "&scope=" + scope;
|
||||
if (state != null) {
|
||||
|
||||
Reference in New Issue
Block a user