2012-03-01 35 views
0

我一直在努力研究這個問題,現在試圖使此驗證與Desk.com的API http://dev.desk.com/一起使用。我甚至嘗試過使用框架分叉如https://github.com/buildmaster/oauth-mvc.net#readme,但我仍然得到401錯誤...我永遠不會授權。無法通過Desk.com獲取401錯誤OAuth

我不能去另一天與此不working..and對這個already..This呆了幾天,就是我全部的自定義代碼在這裏,我一直在敲打着我的大腦試圖找出爲什麼臺。 com拒絕我第一次嘗試在這裏向他們發出API調用。

Desk.com說它必須是我的簽名,但我一遍又一遍地檢查了我的簽名,我覺得簽名不是問題。我甚至嘗試過使用oauth-mvc.net並使用它們的實用程序來創建我的簽名(https://github.com/buildmaster/oauth-mvc.net#readme),並且在使用該框架的sig創建時仍然得到了401回。所以我不能確定它是否是簽名,它要麼是我如何形成請求的簡單愚蠢......我不確定。

所以這裏是我的代碼..我看不到我的生活出了什麼問題。只要按照它,就好像你在和我一起調試。 (僅供參考,如果您看不到它,請右鍵單擊圖像並選擇查看以查看完整圖片)。

1_UnitTestStart.jpg enter image description here 2_AboutToCreateSignature.jpg enter image description here 2_AboutToCreateSignature_2.jpg enter image description here 3_AboutToCreateSignatureBase.jpg enter image description here 4_AboutToEncodeEachKeyAndValue.jpg enter image description here 6_AboutToSortEncodedParamList.jpg enter image description here 7_ParamListIsSorted.jpg enter image description here 8_AboutToNormal izeTheSortedParamList.jpg enter image description here 9_SortedParamListIsNowNormalized.jpg enter image description here 10_ShowingMyUrlEncodeMethodHere.jpg enter image description here 11_BaseSignatureStringCreated.jpg enter image description here 12_SigningTheHMACSHA1.jpg enter image description here 13_ConvertingToHash.jpg enter image description here 14_Hashed.jpg enter image description here 15_ReturnFinalSignature.jpg enter image description here 16_AboutToGetAuthHeaderParamsNorm alizedForRequestHeader.jpg enter image description here 16_AboutToGetAuthHeaderParamsNormalizedForRequestHeader_2.jpg enter image description here 17_ParamsAreNormalizedForRequestHeader.jpg enter image description here 18_AboutToSendAPIRequestToGetAllCases.jpg enter image description here 19_AboutToCreateTheHttpWebRequest.jpg enter image description here 20_AboutToAddHeadersToRequest.jpg enter image description here 20_AboutToAddHeadersToRequest_2.jpg enter image description here 21_AboutToSendTheRequest.jpg enter image description here 22_ViewOfRequestInfoBeforeSending.jpg enter image description here 23_Response401Error。JPG enter image description here 24_Fiddler_RequestDetails.jpg enter image description here 24_Fiddler_RequestDetails_2.jpg enter image description here 24_Fiddler_RequestDetails_3.jpg enter image description here 24_Fiddler_RequestDetails_4.jpg enter image description here

+0

什麼是地獄?誰投票結束這個,爲什麼 – PositiveGuy 2012-03-01 08:54:34

+0

我不認爲它應該被關閉。但在我看來,由於圖像原因,這個問題寫得不好。因爲他們的立場,他們是不可讀的(好吧,你可以放大,但我不認爲人們會打擾) – AnarchistGeek 2012-03-01 09:30:16

+0

是的事情是,我必須寫太多,這樣的圖片會加快速度並使其更多在這種情況下清楚。 OAuth是複雜的...所以它不是我想要的,我想顯示代碼不工作。 – PositiveGuy 2012-03-01 15:21:52

回答

0
的時間

99%,無效的簽名意味着有本人簽字的基本字符串的問題。讓你的代碼隨時登錄這個值,因爲你將需要在某一時刻或其他...

它看起來像你的基地簽名字符串不包含oauth_version PARAM。你的簽名庫應該包含所有以oauth_開頭的參數和任何查詢字符串參數(但它看起來不像你在qs中發送任何東西)。

+0

我其實已經嘗試添加版本,沒有運氣。對於這個調用,我正在執行一個GET來獲取客戶或案例的列表......這樣的東西......只是得到一堆記錄。對於這個API,沒有必要的參數來做到這一點。我只是擊中了resourceName.json端點...所以這就是爲什麼我沒有querystrings。另外我使用HttpRequestHeader發送內容,即使我必須發送數據,我也不想使用querystrings的路線。它只是建議使用頭,而不是查詢字符串,對我來說它也更清潔。 – PositiveGuy 2012-03-04 21:59:11

0

這是一個相當晚的答案,但如果其他人有問題,它可能會有所幫助。

您可以使用RestSharp簡化與desk.com API工作。我有一些問題首先讓OAuth工作,但是在將RestSharp添加到項目後,事情變得更加簡單了。我已經爲此製作了一個小型SDK。這還遠遠沒有完成,但你可以抓住的源代碼,看看如何建立連接:

http://danielsaidi.github.com/desk-csharp-sdk/