Search code examples
javavimeo-apiscribe

Can't extract token and secret from this: '401 Unauthorized - Invalid signature


I'm trying to access to Vimeo API by scribejava. I'm getting this error.

Exception in thread "main" com.github.scribejava.core.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '401 Unauthorized - Invalid signature - The oauth_signature passed was not valid. this is snippet of code

private static final String PROTECTED_RESOURCE_URL = "http://vimeo.com/oauth/authorize?oauth_token=%s";

 final OAuth10aService service = new ServiceBuilder()
            .apiKey(myApiKey)
            .apiSecret(myapiSecret)
            .callback("http://fesal.hostkda.com/5-youtube-video/")
            .build(VimeoApi.instance());

    final OAuth1RequestToken requestToken = service.getRequestToken();


    // Trade the Request Token and Verfier for the Access Token
    final OAuth1AccessToken accessToken = service.getAccessToken(requestToken, oauthVerifier);

    // Now let's go and ask for a protected resource!
     final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
    service.signRequest(accessToken, request);
    final Response response = service.execute(request);
    System.out.println(response.getBody());

virsion of scribejava : 4.0.0

cause of scribe don't support vimeo api , i had created custom one : this is code:

public class VimeoApi extends DefaultApi10a {
private static final String AUTHORIZATION_URL = "https://api.vimeo.com/oauth/authorize";

private static class InstanceHolder {

    private static final VimeoApi INSTANCE = new VimeoApi();
}

public static VimeoApi instance() {
    return InstanceHolder.INSTANCE;
}

@Override
public String getAccessTokenEndpoint() {
    return "http://vimeo.com/oauth/access_token";
}

@Override
public String getRequestTokenEndpoint() {
    return "http://vimeo.com/oauth/request_token";
}

@Override
public String getAuthorizationUrl(OAuth1RequestToken requestToken) {
    return String.format(AUTHORIZATION_URL, requestToken.getToken());
}}

I'm willing to get help from u


Solution

  • OAuth 1 is no longer supported in the Vimeo API. You need to use OAuth 2, as described here: https://developer.vimeo.com/api/authentication