0
votes

.. I am hitting invalid signature error.Can someone help me with this?Am I missing something ? Oauth_token is the access token i get after authorization

URL:vimeo.com/api/rest/v2?method=vimeo.oauth.checkAccessToken

Base String: GET&http%3A%2F%2Fvimeo.com%2Fapi%2Frest%2Fv2&method%3Dvimeo.oauth.checkAccessToken%26oauth_consumer_key%3D763ebd960af20c4844be38d388299f62%26oauth_nonce%3D-5297335925725406200%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1329134906%26oauth_token%3Da61b496a94ebdaa151f1b757bdd54ad7%26oauth_version%3D1.0

HEADER:OAuth oauth_consumer_key="763ebd960af20c4844be38d388299f62", oauth_nonce="-5297335925725406200", oauth_signature="0xBOoOtHG%2BoiAImx3no0bUTTFeU%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1329134906", oauth_token="a61b496a94ebdaa151f1b757bdd54ad7", oauth_version="1.0" 

2

2 Answers

0
votes

Don't know whether you're still having a problem with this, but you might try using scribe. I've been developing an application for vimeo and relying heavily on Scribe to sign and send my requests. Here's an example for authentication and signing and sending a request:

  private static OAuthService service;
  private static Token accessToken;
  private static String newline = System.getProperty("line.separator");

  public static void main(String[] args) throws Exception {
    // Replace these with your own api key and secret

    String apiKey = "YOUR_API_KEY"; //Give your own API Key
    String apiSecret = "YOUR_API_SECRET"; //Give your own API Secret
    String vimeoAPIURL = "http://vimeo.com/api/rest/v2";
    service = new ServiceBuilder().provider(VimeoApi.class).apiKey(apiKey).apiSecret(apiSecret).build();

    OAuthRequest request;
    Response response;

    accessToken = new Token("AN_INVALID_TOKEN_WILL", "REQUIRE_GETTING_A_NEW_ONE"); //Copy the new token you get here

    accessToken = checkToken(vimeoAPIURL, accessToken, service);
    if (accessToken == null) {
      return;
    }
 }

  /**
  * Checks the token to make sure it's still valid. If not, it pops up a dialog asking the user to
  * authenticate.
  */
  private static Token checkToken(String vimeoAPIURL, Token vimeoToken, OAuthService vimeoService) {
    if (vimeoToken == null) {
      vimeoToken = getNewToken(vimeoService);
    } else {
      OAuthRequest request = new OAuthRequest(Verb.GET, vimeoAPIURL);
      request.addQuerystringParameter("method", "vimeo.oauth.checkAccessToken");
      Response response = signAndSendToVimeo(request, "checkAccessToken", true);
      if (response.isSuccessful()
              && (response.getCode() != 200 || response.getBody().contains("<err code=\"302\"")
              || response.getBody().contains("<err code=\"401\""))) {
        vimeoToken = getNewToken(vimeoService);
      }
    }
    return vimeoToken;
  }

  /**
  * Gets authorization URL, pops up a dialog asking the user to authenticate with the url and the user
  * returns the authorization code
  *
  * @param service
  * @return
  */
  private static Token getNewToken(OAuthService service) {
    // Obtain the Authorization URL
    Token requestToken = service.getRequestToken();
    String authorizationUrl = service.getAuthorizationUrl(requestToken);
    do {
      String code = JOptionPane.showInputDialog("The token for the account (whatever)" + newline
              + "is either not set or is no longer valid." + newline
              + "Please go to the URL below and authorize this application." + newline
              + "Paste the code you're given on top of the URL here and click \'OK\'" + newline
              + "(click the 'x' or input the letter 'q' to cancel." + newline
              + "If you input an invalid code, I'll keep popping up).", authorizationUrl + "&permission=delete");
      if (code == null) {
        return null;
      }
      Verifier verifier = new Verifier(code);
      // Trade the Request Token and Verfier for the Access Token
      System.out.println("Trading the Request Token for an Access Token...");
      try {
        Token token = service.getAccessToken(requestToken, verifier);
        System.out.println(token); //Use this output to copy the token into your code so you don't have to do this over and over.
        return token;
      } catch (OAuthException ex) {
        int choice = JOptionPane.showConfirmDialog(null, "There was an OAuthException" + newline
                + ex + newline
                + "Would you like to try again?", "OAuthException", JOptionPane.YES_NO_OPTION);
        if (choice == JOptionPane.NO_OPTION) {
          break;
        }
      }
    } while (true);
    return null;
  }

  /**
  * Signs the request and sends it. Returns the response.
  *
  * @param request
  * @return response
  */
  public static Response signAndSendToVimeo(OAuthRequest request) throws org.scribe.exceptions.OAuthException {
    service.signRequest(accessToken, request);
    Response response = request.send();
    return response;
  }
0
votes

Guys I have almost similar problem.

I was working with basic calls and everything worked fine. But I realized that basic only allows you to query 60 videos. 20 videos per page. Below is the link where I tried to implement paging with basic but the code works for three pages only i.e. 30 videos.

http://projects.tk-fn.com/controls/Vimeo/BKBVideoPage-Backup.html

Then I tried the advanced api which allows 50 per page and unlimited videos. I was able to do all that OAuth implementation but the problem is now that the url works fine when I put it in browser but doesnt work when i try to make JSONP ajax call. :(

http://projects.tk-fn.com/controls/Vimeo/OAuthSimple.html

For those who do know. OAuth takes in all the required parameters like Consumer_Key, Secret, NONE (random string), timestamp, oauth_signature (created by using the entire url).

I found a class by the name of Simple OAuth and used it.

REFRESH page to get correct url every time. URL cannot be used more than once. Vimeo will expect new url on every request.