2013-10-02 24 views
1

我試圖從Xamarin.iOS應用程序中調用VIMEO REST API,但我不斷收到401 VIMEO無效的OAuth簽名:The oauth_signature passed was not valid.與Xamarin.Auth

下面的代碼:

public async Task GetAll (string userId) 
{ 
    var request = OAuth1.CreateRequest (
     "GET", 
     new Uri ("http://vimeo.com/api/rest/v2"), 
     new Dictionary<string, string> { 
      {"user_id", userId}, 
      {"format", "json"}, 
      {"method", "vimeo.video.getAll"} 
     }, 
     CONSUMERKEY, CONSUMERSECRET, TOKENSECRET); 

    var response = await request.GetResponseAsync(); 
    using (var stream = response.GetResponseStream()) 
    using (var reader = new StreamReader (stream, System.Text.Encoding.UTF8)) { 
     Console.WriteLine (request.RequestUri); 
     Console.WriteLine(reader.ReadToEnd()); 
    } 
} 

該請求看起來是星期形成的,但它無論如何失敗。任何提示?

+0

我不能什麼可能是你的代碼錯誤發表評論,但如果你把你的客戶端ID,以及一些示例請求和響應到https: //vimeo.com/help/contact我可能能夠幫助您找出問題所在。 – Dashron

+0

我試過並得到了「我們不提供API支持」類型的答案。但無論如何感謝。 –

回答

3

通過比較Xamarin.Auth生成的BaseString和http://oauth.googlecode.com/svn/code/javascript/example/signature.html生成的BaseString,我發現oath_token參數丟失。

我通過手動添加它固定我的問題:

public async Task GetAll (string userId) 
{ 
    var request = OAuth1.CreateRequest (
     "GET", 
     new Uri ("http://vimeo.com/api/rest/v2"), 
     new Dictionary<string, string> { 
      {"user_id", userId}, 
      {"format", "json"}, 
      {"method", "vimeo.video.getAll"}, 
      {"oauth_token", ACCESSTOKEN}, 
     }, 
     CONSUMERKEY, CONSUMERSECRET, TOKENSECRET); 

    var response = await request.GetResponseAsync(); 
    using (var stream = response.GetResponseStream()) 
    using (var reader = new StreamReader (stream, System.Text.Encoding.UTF8)) { 
     Console.WriteLine (request.RequestUri); 
     Console.WriteLine(reader.ReadToEnd()); 
    } 
} 
相關問題