I have tried two different approach to do vimeo advanced api authentication (which include vimeo search api authentication in this case) and I were not successful using any of them. Please find both the approaches:-

1st Approach:

#!perl + + use strict; use warnings; use Digest::HMAC_SHA1; use Data::Dump qw /dump/; use URI::Escape; use Net::OAuth; use MIME::Base64; use LWP::UserAgent; # Authorize a user + + my $consumer_key = "CONSUMERKEY"; my $secret = "SECRET"; my $method = "vimeo.videos.search" ; my $oauth_nonce = int( rand( 2**32 ) ) ; my $timestamp = time ; my $query = "happy" ; my $url = "http://vimeo.com/api/rest/v2/" ; my $str = "method=$method&oauth_consumer_key=$consumer_key&oauth_non +ce=$oauth_nonce&oauth_signature_method=HMAC-SHA1&oauth_timestamp=$tim +estamp&oauth_version=1.0&query=$query"; $str = uri_escape( $str) ; $url = uri_escape( $url) ; my $secret_key = $secret . '&'; my $base_str = "GET" . "&" . $url . "&" . $str ; my $hmac = Digest::HMAC_SHA1->new( $secret_key ) ; $hmac->add($base_str) ; my $oauth_signature = $hmac->b64digest ; $oauth_signature = encode_base64($oauth_signature ); chomp $oauth_signature; $oauth_signature = uri_escape( $oauth_signature ); my $v_search_url = "http://vimeo.com/api/rest/v2? method=$method&oauth +_consumer_key=$key&oauth_nonce=$oauth_nonce&oauth_signature_method=HM +AC-SHA1&oauth_timestamp=$timestamp&oauth_version=1.0&oauth_signature= +$oauth_signature&query=$query" ; my $browser = LWP::UserAgent->new; my $res = $browser->get( $v_search_url ); print $res->content; The response content throws following error:- <?xml version="1.0" encoding="UTF-8"?> <rsp generated_in="0.0024" stat="fail"> <err code="401" expl="The consumer key passed was not valid." msg= +"Invalid consumer key"/> </rsp>

The consumer key used above is a valid one (Not shared though on top). On hitting the above search url directly on mozilla browser throws this error: "The oauth_signature passed was not valid." Please let me know where exactly the code is having error. I have followed the oauth spec provided at: http://vimeo.com/api/docs/oauth

2nd Approach:

#!perl + + use strict; use warnings; use Digest::HMAC_SHA1; use Data::Dump qw /dump/; use URI::Escape; use Net::OAuth; use Net::OAuth::RequestTokenRequest; use MIME::Base64; use LWP::UserAgent; # Authorize a user + + my $consumer_key = "586a3643bbc31e113205ab62afd86689"; my $secret = "1ff16d3829274918"; my $method = "vimeo.videos.search" ; my $oauth_nonce = int( rand( 2**32 ) ) ; my $timestamp = time ; my $query = "happy" ; my $url = "http://vimeo.com/oauth/request_token"; my $request = Net::OAuth::RequestTokenRequest->new( consumer_key => $consumer_key, consumer_secret => $secret, request_url => $url, request_method => 'GET', signature_method => 'HMAC-SHA1', timestamp => $timestamp, nonce => $oauth_nonce, ); die "COULDN'T GET REQUEST SIGN! Check parameters.\n" unless $request-> +sign; die "COULDN'T VERIFY! Check OAuth parameters.\n" unless $request->veri +fy; my $browser = LWP::UserAgent->new; my $post_body = $request->to_post_body; $post_body = "oauth_callback=oob&" . $post_body; my $post_url = $url . '/?' . $post_body; my $res = $browser->get( $post_url ); die $res->status_line unless ($res->is_success); print $res->content;

This method is also failing by throwing above error stating "The consumer key passed was not valid.".

As using Net::Oauth - its giving error in the first step itself, I cannot proceed further. Any inputs will be sincerely appreciated.


In reply to Perl + vimeo | Getting error in authenticating advanced API's by singh.ashwini

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.