I have next part of code :
using (var client = new HttpClient()) // from Windows.Web.Http;
{
//setup client
var tokenUri = new Uri(apiBaseUri + "/token");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new HttpMediaTypeWithQualityHeaderValue("application/json"));
//setup login data
IHttpContent formContent = new HttpFormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", userName),
new KeyValuePair<string, string>("password", password),
});
//send request
HttpResponseMessage responseMessage = await client.PostAsync(tokenUri, formContent);
//get access token from response body
var responseJson = await responseMessage.Content.ReadAsStringAsync();
var jObject = JObject.Parse(responseJson);
return jObject.GetValue("access_token").ToString();
}
This makes call to my Web Api. I have checked if it's really works with fiddler - as result I can see response what i espect (Bearer token). But in code this response are never received.
What is the problem?