Skip to content

微信OAuth验证后,根据code获取成员信息这里的API有问题 #190

Closed

Description

@constanine

me.chanjar.weixin.cp.api.WxCpServiceImpl这个类 oauth2getUserInfo方法有问题

以下是原码
@OverRide
public String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
+ "code=" + code
+ "&agentid=" + agentId;
String responseText = get(url, null);
JsonElement je = new JsonParser().parse(responseText);
JsonObject jo = je.getAsJsonObject();
return new String[]{GsonHelper.getString(jo, "UserId"), GsonHelper.getString(jo, "DeviceId"), GsonHelper.getString(jo, "OpenId")};
}

但是微信文档中说明了根据code获取成员信息
url参数已经改为了access_token,code,agentid
例如:https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE&agentid=AGENTID
详见http://qydev.weixin.qq.com/wiki/index.php?title=%E6%A0%B9%E6%8D%AEcode%E8%8E%B7%E5%8F%96%E6%88%90%E5%91%98%E4%BF%A1%E6%81%AF
那么显然这里的处理是有问题的
@binarywang

Activity

  1. constanine commented on Apr 18, 2017

    @constanine
    Author

    抱歉没看到后面executeInteranl的方法,不管如何都会带上accesstoken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions