1

I'm trying to call the vimeo REST API from within a Xamarin.iOS application, but I keep getting a 401: The oauth_signature passed was not valid.

Here's the code:

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 ());
    }
}

The request looks week-formed, but it fails anyway. Any hint ?

Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85
  • I can't comment on what might be wrong with your code, but if you send your client id, and some example requests and responses to https://vimeo.com/help/contact I might be able to help you track down what the problem might be. – Dashron Oct 03 '13 at 15:30
  • I tried and got a "we don't provide API support" type of answer. but Thanks anyway. – Stephane Delcroix Oct 04 '13 at 12:26

1 Answers1

3

By comparing the BaseString generated by Xamarin.Auth and the one generated by http://oauth.googlecode.com/svn/code/javascript/example/signature.html I found out that the oath_token parameter was missing.

I fixed my issue by adding it manually:

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 ());
    }
}
Stephane Delcroix
  • 16,134
  • 5
  • 57
  • 85