我试图通过scribejava访问Vimeo API。我收到了这个错误。
线程中的异常" main" com.github.scribejava.core.exceptions.OAuthException:响应正文不正确。无法从中提取令牌和机密:' 401 Unauthorized - 无效签名 - 传递的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的virsion: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());
}}
我愿意从你那里得到帮助
答案 0 :(得分:0)
Vimeo API不再支持OAuth 1。您需要使用OAuth 2,如下所述:https://developer.vimeo.com/api/authentication