public async Task <IExternalTokenData> GetProfileDataFromProvider(string accessToken) { ExternalTokenData token = null; string requestUri = this.ProfileUri.Replace("{0}", accessToken); HttpContent requestContent = null; using (var client = new HttpClient()) { HttpResponseMessage response = await client.PostAsync(requestUri, requestContent); string content = await response.Content.ReadAsStringAsync(); token = JsonConvert.DeserializeObject <ExternalTokenData>(content); } return(token); }
private static IExternalTokenData MapTo(JwtSecurityToken jwtToken) { int exp; Int32.TryParse(jwtToken.Claims.SingleOrDefault(o => o.Type == "exp")?.Value, out exp); var token = new ExternalTokenData() { aud = jwtToken.Audiences.FirstOrDefault(), email = jwtToken.Claims.SingleOrDefault(o => o.Type == "email")?.Value, email_verified = false, exp = exp, name = jwtToken.Claims.SingleOrDefault(o => o.Type == "name")?.Value, sub = jwtToken.Subject }; return(token); }