public static async Task <IEnumerable <Claim> > GetClaimsFromUserInfoAsync(IdxConfiguration configuration, string accessToken) { Uri userInfoUri = new Uri(IdxUrlHelper.GetNormalizedUriString(configuration.Issuer, "v1/userinfo")); HttpClient httpClient = new HttpClient(); var userInfoResponse = await httpClient.GetUserInfoAsync(new UserInfoRequest { Address = userInfoUri.ToString(), Token = accessToken, }).ConfigureAwait(false); var nameClaim = new Claim( ClaimTypes.Name, userInfoResponse.Claims.FirstOrDefault(x => x.Type == "name")?.Value); return(userInfoResponse.Claims.Append(nameClaim)); }
public void GetNormalizedUriStringWithTrailingSlashInArgument() { string normalized = IdxUrlHelper.GetNormalizedUriString("https://org.okta.com/oauth2/default/", "the/resource"); normalized.Should().Be("https://org.okta.com/oauth2/default/the/resource"); }