【发布时间】:2014-12-23 00:57:05
【问题描述】:
我正在使用 Trello 的 Developer API 的 OAuth 实现将内容发布到列表中。
我已成功提出请求,并从https://trello.com/1/OAuthGetRequestToken 收到了我的oauth_token 和oauth_token_secret
但是当我调用https://trello.com/1/OAuthAuthorizeToken,传递我刚刚收到的oauth_token 时,我得到了“找不到应用程序”的响应。
谁能帮忙?
编辑:这是我从https://trello.com/1/OAuthGetRequestToken 得到的回复
oauth_token=8d0e43fd0cc67726567d49ae5e818852&oauth_token_secret=[secret]
这是我发送的授权标头(在 C# 中转义)
"OAuth oauth_version=\"1.0\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce=\"8335006\", oauth_timestamp=\"1414663625\", oauth_consumer_key=\"9612eaca23c7bdd3eca60dc8c2a8159c\", oauth_signature=\"M6sLyyfHGYXOtQnLJexDx96kbFo=\", oauth_token=\"8d0e43fd0cc67726567d49ae5e818852\""
我做错了什么还是 Trello 的错误?
编辑:我正在使用 RestSharp 调用 Trello API,如下所示:
var client = new RestSharp.RestClient("https://trello.com/");
var request = new RestSharp.RestRequest("1/OAuthAuthorizeToken", Method.GET);
编辑:这是完整的 RestSharp 代码:
var client = new RestSharp.RestClient("https://trello.com/");
var request = new RestSharp.RestRequest("1/OAuthAuthorizeToken", Method.GET);
Uri uri = new Uri(string.Format("{0}/{1}", client.BaseUrl, request.Resource));
string authHeader = GenerateAuthorizationHeader(uri);
//This is the output of GenerateAuthorizationHeader()
//string authHeader = "OAuth oauth_version=\"1.0\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce=\"8335006\", oauth_timestamp=\"1414663625\", oauth_consumer_key=\"9612eaca23c7bdd3eca60dc8c2a8159c\", oauth_signature=\"M6sLyyfHGYXOtQnLJexDx96kbFo=\", oauth_token=\"8d0e43fd0cc67726567d49ae5e818852\"";
request.AddHeader("Authorization", authHeader);
GenerateAuthorizationHeader 方法使用OAuth.OAuthBase 为 OAuth 请求生成时间戳和签名。
【问题讨论】:
-
能否分享一下您使用哪个 C# 组件与 Trello api 进行通信。
-
@LouisLewis 我刚刚更新了问题以表明我正在使用 RestSharp,并给出了我正在使用的代码。
-
嗨,马丁,感谢您的补充,现在图片变得更加清晰了。您的代码中有一部分我没有看到,您如何尝试将授权标头与 RestSharp 一起使用?您能否分享您从中提取 sn-p 的“代码块”。我问这个的原因是因为使用 RestSharp 它有帮助身份验证令牌的方法。看到“代码块”将让用户看到“整体”图片并为您提供相应的帮助。
-
@LouisLewis 我刚刚又更新了。
标签: c# api oauth console-application trello