title: oAuth refresh token Fiddler, c# restsharp example for desktop app
body: <p>Been trying to figure oauth out for many hours so I can make product calls in a desktop app. I am able to use the Access token that is generated by the developer console to make http Get calls using restsharp but I cannot get a Put to work to get a new access token after the old one expires which is an hour. I also tried to use fiddler but keep getting "HTTP 400 bad request" errors.</p>
  
  <p>ChannelAdvisor Developer-DOCUMENTATION: <a href="https://developer.channeladvisor.com/authorization/oauth-2-0-authorization-flow" rel="nofollow noreferrer">Link</a></p>
  
  <p><strong>Updating the Access Token</strong></p>
  
  <p>(Excuse my ignorance of not knowing how to jump to <strong>Updating the Access Token</strong> on a page as well.)</p>
  
  <p>I can not get this to work in Restsharp, after hundreds of post and forums on oauth, restsharp google examples, anything. Trying to get any response other than the http 400 or invalid_client is maddening. This was what a post said to do as a workaround because restsharp auto-magically added things to the call and thought it had merit using the clear parameters. </p>
  
  <p>RestSharp Code</p>
  
  <pre><code>string s = Convert.ToBase64String(Encoding.ASCII.GetBytes(creds.appID + ":" + creds.sharedSecret));
  
  var client2 = new RestClient("https://api.channeladvisor.com/oauth2/token?grant_type=refresh_token&amp;refresh_token=" + creds.refreshToken);
  
  var request2 = new RestRequest();
  request2.Method = Method.POST;
  request2.Parameters.Clear();            
  request2.AddHeader("Authorization", s);
  request2.AddHeader("Content-Type", " application/x-www-form-urlencoded");
  request2.AddHeader("Cache-Control", "no-cache");
  
  IRestResponse response2 = client2.Execute(request2);
  </code></pre>
  
  <p>So i went to fiddler and just pasted the example code into the scratchpad and added my tokens, to no avail.</p>
  
  <pre><code>POST /oauth2/token HTTP/1.1
  Host: api.channeladvisor.com
  Authorization: Basic MY_ENCODED_APPID:SHARED_SECRET
  Content-Type: application/x-www-form-urlencoded
  Cache-Control: no-cache
  
  grant_type=refresh_token&amp;refresh_token=xxxxxxxxxxxxxxxxxxxxxmNZtF-cpLy44DV4DQ9Q
  </code></pre>
  
  <p>This is returning 400 error as well. The soap API was simple with authentication username, password but I need a little bit more information that soap does not offer. Any help is appreciated, preferably a fiddler or restsharp example using channel advisors call format.</p>