Skip to content

Commit

Permalink
fix binarywang#1590 提及的me.chanjar.weixin.open.api.impl.WxOpenComponen…
Browse files Browse the repository at this point in the history
…tServiceImpl#getAuthorizerAccessToken()刷新AccessToken后没有同步对应的refreshToken
  • Loading branch information
einsitang committed Jul 20, 2020
1 parent 3c71a36 commit 3d54c1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ public interface WxOpenConfigStorage {
*/
void setAuthorizerRefreshToken(String appId, String authorizerRefreshToken);

/**
* setAuthorizerRefreshToken(String appId, String authorizerRefreshToken) 方法重载方法
* @param appId the app id
* @param authorizerRefreshToken the authorizer refresh token
*/
void updateAuthorizerRefreshToken(String appId, String authorizerRefreshToken);

/**
* Gets authorizer access token.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ public String getAuthorizerAccessToken(String appId, boolean forceRefresh) throw

WxOpenAuthorizerAccessToken wxOpenAuthorizerAccessToken = WxOpenAuthorizerAccessToken.fromJson(responseContent);
config.updateAuthorizerAccessToken(appId, wxOpenAuthorizerAccessToken);
config.updateAuthorizerRefreshToken(appId,wxOpenAuthorizerAccessToken.getAuthorizerRefreshToken());
return config.getAuthorizerAccessToken(appId);
} catch (InterruptedException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public void setAuthorizerRefreshToken(String appId, String authorizerRefreshToke
updateToken(authorizerRefreshTokens, appId, authorizerRefreshToken, null);
}

@Override
public void updateAuthorizerRefreshToken(String appId, String authorizerRefreshToken) {
this.setAuthorizerRefreshToken(appId,authorizerRefreshToken);
}

@Override
public String getAuthorizerAccessToken(String appId) {
return getTokenString(authorizerAccessTokens, appId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@
package me.chanjar.weixin.open.bean;

import lombok.Data;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;

import java.io.Serializable;

/**
* @author <a href="https://github.com/007gzs">007</a>
*/
@Data
public class WxOpenAuthorizerAccessToken implements Serializable {
private static final long serialVersionUID = -4069745419280727420L;

private String authorizerAccessToken;

private String authorizerRefreshToken;

private int expiresIn = -1;

public static WxOpenAuthorizerAccessToken fromJson(String json) {
return WxOpenGsonBuilder.create().fromJson(json, WxOpenAuthorizerAccessToken.class);
}

public String getAuthorizerAccessToken() {
return authorizerAccessToken;
}

public void setAuthorizerAccessToken(String authorizerAccessToken) {
this.authorizerAccessToken = authorizerAccessToken;
}

public int getExpiresIn() {
return expiresIn;
}

public void setExpiresIn(int expiresIn) {
this.expiresIn = expiresIn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public WxOpenAuthorizerAccessToken deserialize(JsonElement jsonElement, Type typ
WxOpenAuthorizerAccessToken authorizerAccessToken = new WxOpenAuthorizerAccessToken();
JsonObject jsonObject = jsonElement.getAsJsonObject();
authorizerAccessToken.setAuthorizerAccessToken(GsonHelper.getString(jsonObject, "authorizer_access_token"));
authorizerAccessToken.setAuthorizerRefreshToken(GsonHelper.getString(jsonObject, "authorizer_refresh_token"));
authorizerAccessToken.setExpiresIn(GsonHelper.getPrimitiveInteger(jsonObject, "expires_in"));
return authorizerAccessToken;
}
Expand Down

0 comments on commit 3d54c1f

Please sign in to comment.