2015-12-07 158 views
1

我只是無法解決這個問題,現在有幾天,任何人有任何想法?下面是請求響應,如Fiddler 所示。響應是oauth_signature不存在,但是它已發送。如果我錯誤地計算了簽名,我會期待signature_invalid 我覺得這個問題正在困擾着我,但我看不到它。雅虎Messenger API - parameter_absent:oauth_signature

GET  http://developer.messenger.yahooapis.com /v1/session HTTP/1.1 
Authorization: OAuth 
realm: "yahooapis.com" 
oauth_version: "1.0" 
oauth_token: "The oauth token " 
oauth_nonce: "4724376" 
oauth_timestamp: "1449488987" 
oauth_consumer_key: "My consumer key" 
oauth_signature_method: "HMAC-SHA1" 
oauth_signature: "oBjiENcrXBX6I5dE/Vr7AHj2FOA=" 
Content-Type: application/json;charset=utf-8 
Host: developer.messenger.yahooapis.com 

HTTP/1.1 401 Authorization Required 
Date: Mon, 07 Dec 2015 11:49:34 GMT 
WWW-Authenticate: OAuth oauth_problem="parameter_absent:  oauth_signature", realm="yahooapis.com" 
Connection: close 
Transfer-Encoding: chunked 
Content-Type: application/xml 
Cache-Control: private 

17b 
<?xml version='1.0' encoding='UTF-8'?> 

Please provide valid credentials. OAuth oauth_problem="parameter_absent:  oauth_signature", realm="yahooapis.com" 

非常感謝 喬恩

回答

0

發現了問題: 我創建的每個驗證項目,一個新的請求頭。所有OAuth令牌都必須放在同一個標​​頭中。即。授權標頭

下面的代碼是我如何添加創建授權標頭,現在工作正常。

string OAuthHeader = "OAuth realm=\"yahooapis.com\"," + 
      "oauth_consumer_key=\"" + consumerkey + "\"," + 
      "oauth_timestamp=\"" + timestamp + "\"," + 
      "oauth_nonce=\"" + nonce + "\"," + 
      "oauth_version=\"1.0\"," + 
      "oauth_signature_method=\"PLAINTEXT\"," + 
      "oauth_token=\"" + dictGetRequestTokenParams["oauth_token"] + "\"," + 
      "oauth_signature=\"" + consumerSecret + "%26" + dictGetRequestTokenParams["oauth_token_secret"] + "\","; 

     request.Headers.Add(HttpRequestHeader.Authorization, OAuthHeader);