using System.Collections.Generic;
namespace SampleIETPLogin
public string access_token { get; set; }
public int access_token_lifetime_minutes { get; set; }
public string username { get; set; }
public string role { get; set; }
public static void Main(string[] args)
using (var client = new HttpClient())
var credentials = new Dictionary<string, string>
{ "username", "ClientApp" },
{ "password", "~!,IetPClient~0b" }
"https://ietp.obds.net/test/api/account/login",
new FormUrlEncodedContent(credentials)
string authResultAsJSONString = resp.Content.ReadAsStringAsync().Result;
var authResultObject = Json.JsonParser.Deserialize<AuthResult>(authResultAsJSONString);
Console.WriteLine("Token is \"{0}\" without quotes", authResultObject.access_token);
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authResultObject.access_token);
var authorizedResp = client.GetAsync("https://ietp.obds.net/test/api/monitor/service").Result;
string authorizedRespAsJSONString = authorizedResp.Content.ReadAsStringAsync().Result;
Console.WriteLine(authorizedRespAsJSONString);