private static UserInfoDto Map(UserInfoRawResponse raw) { return (new UserInfoDto { UserID = raw.sub, AvatarImageUrl = raw.picture, Email = raw.email, FullName = raw.name, IsEmailVerified = raw.email_verified, LastChangedAt = raw.updated_at, Nickname = raw.nickname, }); }
public async Task <UserInfo> GetUserInfo(string accessToken) { using (var http = new HttpClient()) { http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); using (HttpResponseMessage response = await http.GetAsync(userInfoUrl) ) { if (!response.IsSuccessStatusCode) { return(null); } UserInfoRawResponse userInfoRawResponse = JsonConvert.DeserializeObject <UserInfoRawResponse>(await response.Content.ReadAsStringAsync()); return (new UserInfo(Map(userInfoRawResponse))); } } }