我正在努力弄清楚如何从我的Windows Phone 7应用程序中使用Trello的OAuth API调用。除了listing of the endpoints之外,API并未真正记录。
这是我到目前为止所拥有的:
public void OnAuthenticateClicked(object sender, EventArgs e)
{
const string consumerKey = "mykey";
const string consumerSecret = "mysecret";
const string baseUrl = "https://trello.com/1";
var client = new RestClient(baseUrl)
{
Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret)
};
var request = new RestRequest("OAuthGetRequestToken", Method.POST);
var response = client.ExecuteAsync(request, HandleResponse);
}
private void HandleResponse(IRestResponse restResponse)
{
var response = restResponse;
Console.Write(response.StatusCode);
}
我收到404
回复,显然有些事情不对。
有什么建议吗?
答案 0 :(得分:2)
不使用ExecuteAsync
似乎使其有效:
RestRequest request = new RestRequest("OAuthGetRequestToken", Method.POST);
IRestResponse response = client.Execute(request);
Console.Write(response.StatusCode);
根据John Sheehan的this post,“异步方案(SL和WP)尚未支持oAuth1”。
答案 1 :(得分:1)
将OAuthGetRequestToken替换为authorize。
答案 2 :(得分:1)
我认为您的基本网址不正确。 请尝试以下方法:
const string baseUrl =" https://api.trello.com/1&#34 ;;