2012-02-13 79 views
0

..我输入无效签名错误。有人可以帮我解决这个问题吗?我错过了什么吗? 的oauth_token是访问令牌后授权使用vimeo apis时出现303无效签名

网址获取:?vimeo.com/api/rest/v2方法= 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”

回答

0

不知道你是否仍然有这个问题,但你可以尝试使用scribe。我一直在为vimeo开发一个应用程序,并严重依赖Scribe来签名并发送我的请求。以下是身份验证和签名并发送请求的示例:

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,秘密,NONE(随机字符串),时间戳,oauth_signature(通过使用整个URL创建)。

我发现了一类由简单的OAuth的名称,并用它。

刷新页面每次都得到正确的URL。URL不能多次使用。Vimeo的会想到在每次请求新的URL。