I have an application I am writing to connect to a 3rd party company to receive data from their API. The code works fine below as it is, however they are instructing that my signatures need to be made as headers:
Please provide the oauth signatures as headers instead of query parameters.
This works fine as it is without issue and can pull data successfully:
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("oauth_version", "1.0");
request.AddParameter("oauth_nonce", GenerateNonce());
request.AddParameter("oauth_timestamp", GenerateTimeStamp());
request.AddParameter("oauth_signature_method", OAuthSignatureMethod.PlainText);
request.AddParameter("oauth_consumer_key", _consumerKey);
request.AddParameter("oauth_signature", GenerateSignature());
request.Parameters.Sort(new QueryParameterComparer());
but when I try to make them as headers or inserting the ParameterType.HTTPHeader to the addparameter for the signatures, it gives me a 401 error.
So my question is, how can I turn this into a header as requested? Been searching and reading the various documentation for the last 2 days and found nothing that seems to help.
--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Authorization: OAuth realm="Example",
oauth_consumer_key="0685bd9184jfhq22",
oauth_token="ad180jjd733klru7",
oauth_signature_method="HMAC-SHA1",
oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",
oauth_timestamp="137131200",
oauth_nonce="4572616e48616d6d65724c61686176",
oauth_version="1.0"
Which means for the purposes of your code you'd have to first build a string for the header like so (assuming c#).
string OAuthHeader = String.Format("
oath_version=\"1.0\",oath_consumer_key=\"{0}\",oath_signature_method=\"{1}\",oath_signature=\"{2}\",oath_timestamp=\"{3}\",oath_nonce=\"{4}\"", _consumerKey, OAuthSignatureMethod.PlainText, GenerateSignature(), GenerateTimeStamp(),GenerateNonce());
request.AddHeader("Authorization", OAuthHeader);
Thank you Jonathan, this was exactly what I was stuck on, I knew I had to add it as a string, I just didn't know how to format it and couldn't find anything on it. I did try the add header as you mentioned in your first reply, but that didn't work, at least for them all individually.
--
You received this message because you are subscribed to the Google Groups "RestSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+...@googlegroups.com.
--Jonathan L. Haase
To unsubscribe from this group and stop receiving emails from it, send an email to restsharp+unsubscribe@googlegroups.com.