// https://stackoverflow.com/questions/15176538/net-httpclient-how-to-post-string-value public async Task <bool> GetAccessToken(string pincode) { AuthorizationError = false; string api = Global.Instance.AuthorizationEndpoint; var content = new System.Net.Http.FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("client_id", Global.Instance.ProductID), new KeyValuePair <string, string>("client_secret", Global.Instance.ProductSecret), new KeyValuePair <string, string>("grant_type", "authorization_code"), new KeyValuePair <string, string>("code", pincode) }); using (System.Net.Http.HttpClient client = HttpApiClient()) { try { System.Net.Http.HttpResponseMessage response = await client.PostAsync(api, content); string responseContent = await response.Content.ReadAsStringAsync(); if (responseContent.Contains("error")) { ErrorMessage = Parse.ErrorMessage(responseContent); return(false); } string token = Parse.AccessToken(responseContent); if (!string.IsNullOrEmpty(token)) { AuthToken = token; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; localSettings.Values["NestAccessToken"] = token; } return(true); } catch (Exception ex) { ErrorMessage = ex.Message; } return(false); } }