private async Task<HttpResult<AccessTokenResponse>> GetTokenAsync(IEnumerable<KeyValuePair<string, string>> values)
 {
     try
     {
         using (HttpResponseMessage response = await HttpClient.PostAsync(TokenUri, new FormUrlEncodedContent(values)))
         {
             HttpResult<AccessTokenResponse> result = new HttpResult<AccessTokenResponse>() { StatusCode = response.StatusCode };
             if (response.Content != null)
             {
                 result.Content = await response.Content.ReadAsAsync<AccessTokenResponse>();
             }
             AccessTokenResponse tokenResponse = result.Content;
             if (tokenResponse != null && tokenResponse.Error != null)
             {
                 result.Errors.Add(tokenResponse.ErrorDescription);
             }
             return result;
         }
     }
     catch (HttpRequestException ex)
     {
         return HttpResult<AccessTokenResponse>.Failure(ex.Message);
     }
 }
 string GetRequestFailedMessage(HttpResult result)
 {
     return result.StatusCode != default(HttpStatusCode) ? String.Format("Request failed: {0}", result.StatusCode) : "Request failed.";
 }
 private static void AddAllErrors(HttpResult result, ErrorResponse errorResponse)
 {
     if (errorResponse != null)
     {
         foreach (string error in errorResponse.AllErrors)
         {
             result.Errors.Add(error);
         }
     }
 }