protected override AuthUser getUserInfo(AuthToken authToken) { string response = doGetUserInfo(authToken); var jsonObj = response.parseObject(); this.checkResponse(jsonObj); // 返回 OpenId 或其他,均代表非当前企业用户,不支持 if (!jsonObj.ContainsKey("UserId")) { throw new Exception(AuthResponseStatus.UNIDENTIFIED_PLATFORM.GetDesc()); } string userId = jsonObj.getString("UserId"); string userDetailResponse = getUserDetail(authToken.accessToken, userId); var userDetailObj = userDetailResponse.parseObject(); this.checkResponse(userDetailObj); var authUser = new AuthUser(); authUser.username = userDetailObj.getString("name"); authUser.nickname = userDetailObj.getString("alias"); authUser.avatar = userDetailObj.getString("avatar"); authUser.location = userDetailObj.getString("address"); authUser.email = userDetailObj.getString("email"); authUser.uuid = userDetailObj.getString("userId"); authUser.token = authToken; authUser.source = source.getName(); authUser.gender = GlobalAuthUtil.getWechatRealGender(userDetailObj.getString("gender")); authUser.originalUser = userDetailObj; authUser.originalUserStr = response; return(authUser); }
protected override AuthUser getUserInfo(AuthToken authToken) { string openId = authToken.openId; string response = doGetUserInfo(authToken); var jsonObj = response.parseObject(); this.checkResponse(jsonObj); //string location = String.format("%s-%s-%s", object.getString("country"), object.getString("province"), object.getString("city")); string location = $"{jsonObj.getString("country")}-{jsonObj.getString("province")}-{jsonObj.getString("city")}"; if (jsonObj.ContainsKey("unionid")) { authToken.unionId = jsonObj.getString("unionid"); } var authUser = new AuthUser(); authUser.username = jsonObj.getString("nickname"); authUser.nickname = jsonObj.getString("nickname"); authUser.avatar = jsonObj.getString("headimgurl"); authUser.location = location; authUser.uuid = openId; authUser.gender = GlobalAuthUtil.getWechatRealGender(jsonObj.getString("sex")); authUser.token = authToken; authUser.source = source.getName(); authUser.originalUser = jsonObj; authUser.originalUserStr = response; return(authUser); }