Exemplo n.º 1
0
 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,
     });
 }
Exemplo n.º 2
0
        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)));
                }
            }
        }