Exemplo n.º 1
0
        // Token: 0x0600003B RID: 59 RVA: 0x00002520 File Offset: 0x00000720
        public override async Task <ExternalAuthUserInfo> GetUserInfo(string accessCode)
        {
            ExternalAuthUserInfo result;

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.UserAgent.ParseAdd("Microsoft ASP.NET Core OAuth middleware");
                client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
                client.Timeout = TimeSpan.FromSeconds(30.0);
                client.MaxResponseContentBufferSize = 10485760L;
                HttpResponseMessage httpResponseMessage = await client.SendAsync(new HttpRequestMessage(HttpMethod.Get, GoogleDefaults.UserInformationEndpoint)
                {
                    Headers =
                    {
                        Authorization = new AuthenticationHeaderValue("Bearer", accessCode)
                    }
                });

                httpResponseMessage.EnsureSuccessStatusCode();
                JObject user = JObject.Parse(await httpResponseMessage.Content.ReadAsStringAsync());
                result = new ExternalAuthUserInfo
                {
                    Name         = GoogleHelper.GetName(user),
                    EmailAddress = GoogleHelper.GetEmail(user),
                    Surname      = GoogleHelper.GetFamilyName(user),
                    ProviderKey  = GoogleHelper.GetId(user),
                    Provider     = "Google"
                };
            }
            return(result);
        }
Exemplo n.º 2
0
 // Token: 0x06000042 RID: 66 RVA: 0x000025FE File Offset: 0x000007FE
 public static string GetEmail(JObject user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(GoogleHelper.TryGetFirstValue(user, "emails", "value"));
 }
Exemplo n.º 3
0
 // Token: 0x06000040 RID: 64 RVA: 0x000025C3 File Offset: 0x000007C3
 public static string GetFamilyName(JObject user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(GoogleHelper.TryGetValue(user, "name", "familyName"));
 }