Domanda

I have been able to successfully get an access token from Vimeo using the Scribe API.

However, when I try to access a protected resource, I get an invalid signature error. My OAuthService that I use to try an access a protected resource, looks like:

OAuthService service = new ServiceBuilder()
    .provider(VimeoApi.class)
    .apiKey(APIKEY)
    .apiSecret(API_SECRET)
    .signatureType(SignatureType.QueryString)
    .build();

Then, I make a request doing the following:

  OAuthRequest orequest = new OAuthRequest(Verb.GET, "http://vimeo.com/api/rest/v2");
  orequest.addBodyParameter("method", "vimeo.videos.upload.getQuota");

This fails and tell me that the signature is invalid.

È stato utile?

Soluzione

The problem is,

  orequest.addBodyParameter("method", "vimeo.videos.upload.getQuota");

Scribe then added this parameter to the base string used to form the signature. Vimeo saw that I was doing a GET and that the method parameter was in the request body and not query string, so it did not include it in the base string. Hence, the signature Vimeo expected was different than the one Scribe generated.

I am doing a GET however so I should be passing this parameter on the query string,

  orequest.addQuerystringParameter("method", "vimeo.videos.upload.getQuota");

This works, as would:

  OAuthRequest orequest = new OAuthRequest(Verb.POST, "http://vimeo.com/api/rest/v2");
  orequest.addBodyParameter("method", "vimeo.videos.upload.getQuota");
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top