Skip to content

企业号身份验证

borball edited this page Dec 28, 2016 · 3 revisions

企业号身份认证

###企业获取code

String code = OAuth2s.defaultOAuth2s().authenticationUrl(String redirect, String state);

或者:

String code = OAuth2s.with(corpSetting).authenticationUrl(String redirect, String state);

###根据code获取成员信息

UserInfo user = OAuth2s.defaultOAuth2s().userInfo(String code);

或者:

UserInfo user = OAuth2s.with(corpSetting).userInfo(String code);

###userId转换为openId

//特定agent下:
Map<String, String> map = OAuth2s.defaultOAuth2s().toOpenId(int agentId, String userId);
String appId = map.get("appid");
String openId = map.get("openid");

//企业号下:
String openId = OAuth2s.defaultOAuth2s().toOpenId(String userId);

###openId转换为userid

String openId = OAuth2s.defaultOAuth2s().toUserId(String openId);

微信官方:身份验证