how do i get the identity for an obtained swt token? the identitymodel tests use a webapisecurity endpoint, is that available in the identityserver?
the following code is from a consoleapp and taken from the identitymodel tests (IdSrvOAuth2Client)
static readonly Uri Oauth2Address = new Uri("https://localhost/idsrv/issue/oauth2/token");
private const string BaseAddress = "https://localhost/idsrv/webapisecurity/api";
^^^^ ?????? gives 404
static void Main(string[] args)
{
var swtToken = GetIdentityToken();
"Ok, token received".ConsoleGreen();
var identity = CallService(swtToken); // BOOM: 404
"Ok, identity received".ConsoleGreen();
}
private static string GetIdentityToken()
{
"Requesting swt (oauth2) token from idp".ConsoleYellow();
var client = new OAuth2Client(Oauth2Address, "test", "secret");
var response = client.RequestAccessTokenUserName("admin", "*****", "https://test/rp/");
return response.AccessToken;
}
private static Identity CallService(string swt)
{
"Calling identity service".ConsoleYellow();
var client = new HttpClient { BaseAddress = new Uri(BaseAddress) };
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("IdSrv", swt);
var response = client.GetAsync("identity").Result;
response.EnsureSuccessStatusCode();
return response.Content.ReadAsAsync<Identity>().Result;
}