You must Sign In to post a response.
  • Category: Webservices

    Extract access_token from response

    using (var client = new HttpClient())
    var baseAddress = new Uri("");

    var form = new Dictionary<string, string>
    {"grant_type", "password"},
    {"client_id", "xxx"},
    {"username", ""},
    {"password", "xxxx"}

    HttpResponseMessage response = new HttpResponseMessage();

    using (response = await client.PostAsync(baseAddress, new FormUrlEncodedContent(form)))
    var resultString = response.Content.ReadAsStringAsync();

    I use the above code to make a POST request for getting access_token. How do I get the access_token value that is returned?
  • #770381
    HttpResponseMessage response= client.PostAsync(baseAddress , new FormUrlEncodedContent(postData)).Result;

    //var token = tokenResponse.Content.ReadAsStringAsync().Result;

    token = await tokenResponse.Content.ReadAsAsync<AccessTokenResponse>(new[] {
    new JsonMediaTypeFormatter() })

    B.Ramana Reddy

  • Sign In to post your comments