无法从中提取令牌和秘密:'401 未经授权 - 签名无效

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

我正在尝试通过 scribejava 访问 Vimeo API。我收到这个错误。

线程异常 "main" com.github.scribejava.core.exceptions.OAuthException: 响应正文不正确。无法从中提取令牌和密码:'401 未经授权 - 签名无效 - 传递的 oauth_signature 无效。 这是代码片段

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());

scribejava 版本:4.0.0

因为抄写员不支持 vimeo api,我创建了一个自定义的:这是代码:

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());
}}

我愿意得到你的帮助

Vimeo API 不再支持 OAuth 1。您需要使用 OAuth 2,如下所述:https://developer.vimeo.com/api/authentication