RestSharp OAuth - signature_invalid

63 views
Skip to first unread message

Daniel Hagen

unread,
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("https://openapi.etsy.com/v2");
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&https%3A%2F%2Fopenapi.etsy.com%2Fv2%2Flistings&description%3DTestartikel%252C%2520Bitte%2520nicht%2520kaufen.%26is_supply%3Dfalse%26language%3Dde%26oauth_consumer_key%3Dgn31uuabj1qv97zjqozgnsto%26oauth_nonce%3D02xdjk7bxv4id7mx%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1631170110%26oauth_token%3D8fc58d589855126dd880b3ac74eb1b%26oauth_version%3D1.0%26price%3D0.99%26quantity%3D1%26renew%3DTrue%26shipping_template_id%3D60205488400%26state%3Ddraft%26taxonomy_id%3D6451%26title%3Dtestartikel%2520mit%2520%25C3%2584%26when_made%3D2010_2019%26who_made%3Di_did"

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


David Pierson

unread,
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
Forward
0 new messages