RestSharp OAuth - signature_invalid

Skip to first unread message

Daniel Hagen

Sep 14, 2021, 2:05:08 PM9/14/21
to Etsy API

Hello i have a problem with umlauts (ä,ö,ü) while creating a new listing over the etsy api.
Without ä, ö or ü in my request the api works fine without any problems.

Here is my Code.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var restClient = new RestClient("");
restClient.Authenticator = OAuth1Authenticator.ForAccessToken(etsyCredentials.ConsumerKey, etsyCredentials.ConsumerSecret, etsyCredentials.OAuth_Token, etsyCredentials.OAuth_Token_Secret, RestSharp.Authenticators.OAuth.OAuthSignatureMethod.HmacSha1);

string requestParameters = "/listings?quantity=1&title=testartikel mit Ä&description=Testartikel, Bitte nicht kaufen.&price=0.99&taxonomy_id=6451&who_made=i_did&when_made=2010_2019&is_supply=false&shipping_template_id=60205488400&renew=True&state=draft&language=de";
var request = new RestRequest(requestParameters);
request.Method = Method.POST;

IRestResponse irestResponse = restClient.Execute(request);

And here the Error:

> "oauth_problem=signature_invalid&debug_sbs=POST&"

could someone perhaps tell me what I have to do to successfully create requests with umlauts?

David Pierson

Oct 26, 2021, 8:47:03 AM10/26/21
to Etsy API
I am using Dino Chiesa's OAuth code in my C# app. It is very good. His Sign(string uri, string method) method includes these lines
   byte[] dataBuffer = Encoding.ASCII.GetBytes(signatureBase);
   byte[] hashBytes = hash.ComputeHash(dataBuffer);

Not sure how ASCII.GetBytes would cope with umlauts but I assume badly.

To avoid that, before that code, in GetSignatureBase, he calls UrlEncode method. Excluding the characters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
this is applied to all other characters, such as umlauts:
                    foreach (byte b in Encoding.UTF8.GetBytes(symbol.ToString(CultureInfo.InvariantCulture)))
                        result.Append('%' + String.Format("{0:X2}", b));
Does your library do something similar?
Reply all
Reply to author
0 new messages