I'm trying to do the sample Authorized Request (or anything with Etsy's api that requires authentication) given in their documentation. The response I get is "oauth_problem=token_rejected".
I used this SO answer along with the OAuth base that benSharper linked to.
I've looked at this and this, and others. One of them used https://sandbox.https://openapi.etsy.com/v2
and when I tried that, the exception was "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." I deployed to my server (which is https) and still the same response.
Just can't seem to make it work. What am I missing?
Here's my code:
public class AuthorizedRequestHelper
{
string baseUrl = "https://openapi.etsy.com/v2";
string relativePath = "/oauth/scopes";
string oauth_consumer_key = "xxx";
string consumerSecret = "xxx";
string oauth_token = "xxx";
string oauth_token_secret = "xxx";
public void test()
{
var restClient = new RestClient(baseUrl);
OAuthBase oAuth = new OAuthBase();
string nonce = oAuth.GenerateNonce();
string timeStamp = oAuth.GenerateTimeStamp();
string normalizedUrl;
string normalizedRequestParameters;
string sig = oAuth.GenerateSignature(new Uri(baseUrl + relativePath), oauth_consumer_key, consumerSecret, oauth_token, oauth_token_secret, "GET", timeStamp, nonce, out normalizedUrl, out normalizedRequestParameters);
var request = new RestRequest(relativePath);
request.Resource = string.Format(relativePath);
request.Method = Method.GET;
request.AddParameter("oauth_consumer_key", oauth_consumer_key);
request.AddParameter("oauth_token", oauth_token);
request.AddParameter("oauth_nonce", nonce);
request.AddParameter("oauth_timestamp", timeStamp);
request.AddParameter("oauth_signature_method", "HMAC-SHA1");
request.AddParameter("oauth_version", "1.0");
request.AddParameter("oauth_signature", sig);
IRestResponse irestResponse = restClient.Execute(request);
var content = irestResponse.Content;
// content = oauth_problem=token_rejected
}
}
Any help would be greatly appreciated.