Created
December 5, 2014 13:46
-
-
Save michaelkc/f797866d8e801c9b4c5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wsTrustClient = new WsTrustClient("devtest-idp.vfltest.dk"); | |
var audience = "https://devtest-ws-dli.vfltest.dk/UserServices/"; | |
var token = (GenericXmlSecurityToken)wsTrustClient.GetSecurityToken(audience, "<service account>", "<service account password>"); | |
var tokenXml = token.TokenXml.OuterXml; | |
var encodedToken = new DeflatedSamlTokenHeaderEncoder().Encode(tokenXml); | |
Console.WriteLine(tokenXml); | |
Console.WriteLine(encodedToken); | |
using (var client = new HttpClient()) | |
{ | |
client.BaseAddress = new Uri("https://devtest-ws-dli.vfltest.dk/UserServices/api/users/mac/"); | |
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", encodedToken); | |
HttpResponseMessage response = client.GetAsync("").Result; | |
string content = response.Content.ReadAsStringAsync().Result; | |
Console.WriteLine(response.StatusCode); | |
Console.WriteLine(content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment