windows-phone-7 – 使用RestSharp对Trello API进行身份验证

前端之家收集整理的这篇文章主要介绍了windows-phone-7 – 使用RestSharp对Trello API进行身份验证前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在努力弄清楚如何从我的 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响应,显然有些事情是不对的.

有什么建议?

解决方法

不使用ExecuteAsync似乎使它工作:

RestRequest request = new RestRequest("OAuthGetRequestToken",Method.POST);
IRestResponse response = client.Execute(request);
Console.Write(response.StatusCode);

根据John Sheehan的this post,在某一点上“异步方案(SL和WP)尚未支持oAuth1”.

猜你在找的Windows相关文章