Postmanを使用すると、PostmanのOAuth 1.0 Authorizationを使用して、Twitter API
を使用して適切にクエリし、作成したユーザーを作成できました。しかしRestSharpで同じことをしようとするとUnauthorizedエラーが出ます。OAuth1 RestSharpでのTwitter APIのGETおよびPOSTメソッドの認証
"UNAUTHORIZED_ACCESS" - "このリクエストは正しく認証されていません" -
私のGET
要求は正常に認証されますが、POST要求は失敗します。
_twitterRestClient = new RestClient("https://ads-api.twitter.com/1")
{
Authenticator = OAuth1Authenticator.ForProtectedResource(ConsumerKey, ConsumerSecret, AccessToken, AccessSecret)
};
var restRequest1 = new RestRequest(string.Format("/accounts/{0}/tailored_audiences", TwitterAccountId), Method.GET);
//this works and gives me a list of my tailored audiences
var response1 = _twitterRestClient.Execute(restRequest1);
var restRequest2 = new RestRequest(string.Format("/accounts/{0}/tailored_audiences?name=SampleAudience2&list_type=EMAIL", TwitterAccountId), Method.POST);
// this results in an "Unauthorized" status code , and the message {\"code\":\"UNAUTHORIZED_ACCESS\",\"message\":\"This request is not properly authenticated\"}
var response2 = _twitterRestClient.Execute(restRequest2);