首页 文章

使用vimeo apis时收到错误303无效签名

提问于
浏览
0

..我遇到了无效的签名错误 . 有人帮我这个吗?我错过了什么吗? Oauth_token是授权后获得的访问令牌

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

基底线:GET&HTTP%3A%2F%2Fvimeo.com%2Fapi%2Frest%2Fv2&方法%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 回答

  • 0

    唐't know whether you'仍然有这个问题,但你可能会尝试使用scribe . 我've been developing an application for vimeo and relying heavily on Scribe to sign and send my requests. Here'是一个用于身份验证和签名以及发送请求的示例:

    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

    伙计我有几乎类似的问题 .

    我正在处理基本呼叫,一切正常 . 但我意识到基本只允许你查询60个视频 . 每页20个视频 . 下面是我尝试使用基本实现分页的链接,但代码仅适用于三个页面,即30个视频 .

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

    然后我尝试了高级api,允许每页50个和无限的视频 . 我能够完成所有OAuth实现,但现在的问题是,当我将它放在浏览器中时,url工作正常,但当我尝试进行JSONP ajax调用时,它不起作用 . :(

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

    对于那些知道的人 . OAuth接受所有必需的参数,如Consumer_Key,Secret,NONE(随机字符串),timestamp,oauth_signature(使用整个url创建) .

    我找到了一个名为Simple OAuth的类并使用它 .

    REFRESH页面每次都能获得正确的URL . 网址不能多次使用 . Vimeo希望每个请求都有新网址 .

相关问题