2014-10-27 46 views
3

我正在使用Trello的開發人員API的OAuth實現將內容發佈到列表。Trello API OAuth找不到我的應用

我已經成功地做了一個請求,並得到了我的oauth_tokenoauth_token_secret回從https://trello.com/1/OAuthGetRequestToken

但是,當我打電話https://trello.com/1/OAuthAuthorizeToken,路過我剛剛收到oauth_token,我得到的迴應「找不到應用程式」 。

任何人都可以幫忙嗎?


編輯:這裏就是我從https://trello.com/1/OAuthGetRequestToken

oauth_token=8d0e43fd0cc67726567d49ae5e818852&oauth_token_secret=[secret] 

取回而這裏的Authorization頭我送(逃脫在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請求生成時間戳和簽名。

+0

您可以分享您使用哪種C#組件與Trello API進行通信。 – 2014-11-04 06:45:10

+0

@LouisLewis我剛剛更新了問題以表明我正在使用RestSharp,並給出了我正在使用的代碼。 – martinthebeardy 2014-11-04 10:09:33

+1

嗨馬丁,謝謝你補充說,圖片現在變得更清晰一點。您的代碼中有一部分我沒有看到,您如何試圖在RestSharp上使用授權標頭?你能不能分享一下你把這段代碼拉出來的「代碼塊」。我正在問這個問題的原因是,因爲有了RestSharp,它可以幫助驗證令牌。看到「代碼塊」將允許用戶看到「整個」圖片並相應地爲您提供幫助。 – 2014-11-04 19:39:43

回答

0

我有同樣的問題,這裏的事情是,OAuth是版本1.0 當你從你第一次調用令牌和令牌密鑰,使您的用戶訪問https://trello.com/1/OAuthAuthorizeToken不是你。

你的情況,你有你的用戶重定向到https://trello.com/1/OAuthAuthorizeToken?oauth_token=8d0e43fd0cc67726567d49ae5e818852&scope=read,write,account

他會得到一個頁面,在那裏他可以允許訪問。然後,您將在授權後在頁面中獲得驗證碼,以繼續您的過程(GetAccessToken)。

您可以嘗試這個測試,在真實應用程序中,您必須在OAuthAuthorizeToken調用中指定回調URL和應用程序名稱。