protected override AuthUser GetUserInfo(AuthToken authToken) { string response = DoGetUserInfo(authToken); var userObj = response.ParseObject(); this.checkResponse(userObj); var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("id"); authUser.Username = userObj.GetString("name"); authUser.Nickname = userObj.GetString("name"); authUser.Avatar = userObj.GetString("avatar"); authUser.Blog = userObj.GetString("url"); authUser.Location = userObj.GetString("location"); authUser.Email = userObj.GetString("email"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userObj; authUser.OriginalUserStr = response; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string userResponse = DoGetUserInfo(authToken); var userProfile = userResponse.ParseObject(); this.CheckResponse(userProfile); var userObj = userProfile.GetString("data").ParseObject(); bool isAnonymousUser = userObj.GetInt32("uid_type") == 14; string anonymousUserName = "******"; var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("uid"); authUser.Username = isAnonymousUser ? anonymousUserName : userObj.GetString("screen_name"); authUser.Nickname = isAnonymousUser ? anonymousUserName : userObj.GetString("screen_name"); authUser.Avatar = userObj.GetString("avatar_url"); authUser.Remark = userObj.GetString("description"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userProfile; authUser.OriginalUserStr = userResponse; return(authUser); }
/** * 获取用户的实际性别。华为系统中,用户的性别:1表示女,0表示男 * * @param object obj * @return AuthUserGender */ private AuthUserGender getRealGender(Dictionary <string, object> userObj) { int genderCodeInt = userObj.GetInt32("gender"); string genderCode = genderCodeInt == 1 ? "0" : (genderCodeInt == 0) ? "1" : genderCodeInt + ""; return(GlobalAuthUtil.GetRealGender(genderCode)); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string response = DoGetUserInfo(authToken); var userInfoObject = response.ParseObject(); this.checkResponse(userInfoObject); var userObj = userInfoObject.GetString("data").ParseObject(); var location = $"{userObj.GetString("country")}-{userObj.GetString("province")}-{userObj.GetString("city")}"; var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("union_id"); authUser.Username = userObj.GetString("nickname"); authUser.Nickname = userObj.GetString("nickname"); authUser.Avatar = userObj.GetString("avatar"); authUser.Location = location; authUser.Remark = userObj.GetString("description"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userObj; authUser.OriginalUserStr = response; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string response = DoGetUserInfo(authToken); var resData = response.ParseObject(); this.checkResponse(resData); var userObj = resData.GetString("data").ParseObject(); var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("id"); authUser.Username = userObj.GetString("name"); authUser.Nickname = userObj.GetString("name"); authUser.Avatar = $"{"https://coding.net/"}{userObj.GetString("avatar")}"; authUser.Blog = $"{"https://coding.net/"}{userObj.GetString("path")}"; authUser.Company = userObj.GetString("company"); authUser.Location = userObj.GetString("location"); authUser.Email = userObj.GetString("email"); authUser.Remark = userObj.GetString("slogan"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("sex")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = resData; authUser.OriginalUserStr = response; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string response = DoGetUserInfo(authToken); var userObj = response.ParseObject(); this.checkResponse(userObj); var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("userid"); authUser.Username = userObj.GetString("username"); authUser.Nickname = userObj.GetString("username"); string protrait = userObj.GetString("portrait"); authUser.Avatar = protrait.IsNullOrWhiteSpace() ? null : string.Format("http://himg.bdimg.com/sys/portrait/item/{0}.jpg", protrait); authUser.Remark = userObj.GetString("userdetail"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("sex")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userObj; authUser.OriginalUserStr = response; return(authUser); }
private AuthUserGender getGender(Dictionary <string, object> userObj) { var basicInformation = userObj.GetJSONObject("basicInformation"); if (basicInformation.Count == 0) { return(AuthUserGender.Unknown); } return(GlobalAuthUtil.GetRealGender(basicInformation.GetString("sex"))); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string openId = this.getOpenId(authToken); string response = DoGetUserInfo(authToken); var userObj = response.ParseObject(); if (userObj.GetInt32("ret") != 0) { throw new Exception(userObj.GetString("msg")); } string avatar = userObj.GetString("figureurl_qq_2"); if (avatar.IsNullOrWhiteSpace()) { avatar = userObj.GetString("figureurl_qq_1"); } string location = $"{userObj.GetString("province")}-{userObj.GetString("city")}"; var authUser = new AuthUser(); authUser.Uuid = openId; authUser.Username = userObj.GetString("nickname"); authUser.Nickname = userObj.GetString("nickname"); authUser.Avatar = avatar; authUser.Location = location; authUser.Email = userObj.GetString("email"); authUser.Remark = userObj.GetString("bio"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userObj; authUser.OriginalUserStr = response; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { var response = DoGetUserInfo(authToken); var userObj = response.ParseObject(); this.checkResponse(userObj); var authUser = new AuthUser { Uuid = userObj.GetString("id"), Username = userObj.GetString("name"), Nickname = userObj.GetString("name"), Avatar = getUserPicture(userObj), Location = userObj.GetString("locale"), Email = userObj.GetString("email"), Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")), Token = authToken, Source = source.GetName(), OriginalUser = userObj, OriginalUserStr = response }; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { var accessToken = authToken.AccessToken; var uid = authToken.Uid; var oauthParam = $"uid={uid}&access_token={accessToken}"; var reqParams = new Dictionary <string, object>(); reqParams.Add("Authorization", "OAuth2 " + oauthParam); reqParams.Add("API-RemoteIP", "application/x-www-form-urlencoded"); string response = HttpUtils.RequestGet(UserInfoUrl(authToken), reqParams); var userObj = response.ParseObject(); if (userObj.ContainsKey("error")) { throw new Exception(userObj.GetString("error")); } var authUser = new AuthUser(); authUser.Uuid = userObj.GetString("id"); authUser.Username = userObj.GetString("name"); authUser.Nickname = userObj.GetString("screen_name"); authUser.Avatar = userObj.GetString("profile_image_url"); authUser.Blog = userObj.GetString("url").IsNullOrWhiteSpace() ? $"{"https://weibo.com/"}{userObj.GetString("profile_url")}" : userObj.GetString("url"); authUser.Location = userObj.GetString("location"); authUser.Remark = userObj.GetString("description"); authUser.Gender = GlobalAuthUtil.GetRealGender(userObj.GetString("gender")); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = userObj; authUser.OriginalUserStr = response; return(authUser); }
protected override AuthUser GetUserInfo(AuthToken authToken) { string accessToken = authToken.AccessToken; AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest(); AlipayUserInfoShareResponse response = null; try { response = this.aopClient.Execute(request, accessToken); } catch (Exception e) { throw new Exception(e.Message, e); } if (response.IsError) { throw new Exception(response.SubMsg); } string province = response.Province, city = response.City; string location = string.Format("{0} {1}", !province.IsNullOrWhiteSpace() ? "" : province, !city.IsNullOrWhiteSpace() ? "" : city); var authUser = new AuthUser(); authUser.Username = response.UserName.IsNullOrWhiteSpace() ? response.NickName : response.UserName; authUser.Nickname = response.NickName; authUser.Avatar = response.Avatar; authUser.Location = location; authUser.Uuid = response.UserId; authUser.Gender = GlobalAuthUtil.GetRealGender(response.Gender); authUser.Token = authToken; authUser.Source = source.GetName(); authUser.OriginalUser = response; authUser.OriginalUserStr = JsonConvert.SerializeObject(response); return(authUser); }