我正在关注this问题以连接Etsy API,并编写了以下代码:
class Etsy
{
private const string ACCESS_TOKEN = "jagbkdwqii82lhiaj2pqcujd ";
private const string SECRET = "is1bztdh2k";
private const string BASE_URL = "https://openapi.etsy.com/v2";
private string token = "";
public Etsy()
{
String f = "";
try
{
var request_token_url = BASE_URL + "/oauth/request_token";
var oauth = new Manager();
oauth["consumer_key"] = ACCESS_TOKEN;
oauth["consumer_secret"] = SECRET;
oauth.AcquireRequestToken(request_token_url, "POST");
f = "REQUIRED TOKENS = " + oauth["token"].ToString();
token = f;
}
catch (Exception ex)
{
Console.WriteLine("Exception: "+ex.Message);
token = "Exception :\n"+ex.Message;
}
}
public string show()
{
return token;
}
}
当我运行此代码时,它会一直出现Unauthorized(401)
错误。我使用相同的凭据到Etsy Python Library然后它工作正常。我在哪里做错了?
更新
我进一步调试,发现它发送了以下标题:
HEADER:- OAuth oauth_callback="oob", oauth_consumer_key="jagbkdwqii82lhiaj2pqcujd", oauth_nonce="150z8543", oauth_signature="4QGkvgBiF%2BQpOYNcNNwWNIIrhJo%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1431409362", oauth_version="1.0"
缺少什么?