PDA

View Full Version : OAuth 2 POST with no request variables.



bouzafr
Mar 27th, 2011, 02:32 PM
This took me a while to find out... I hope you guys will help me out.

Just debugging with Eclipse inside the OAuth classes I found out that when is doing the POST request for the access_token no variables are passed on the body of the POST.

I'm sure that I'm doing something wrong but I don't know why. The first part of the process requesting the code is working fine I can see the code being returned but as soon as is going against the server I get a 400.

So finally I see that on the RestTemplate.class where:


URI expanded = uriTemplate.expand(urlVariables);
return doExecute(expanded, method, requestCallback, responseExtractor);

Empty variables. Please see attached screenshot.

And this is the answer I'm getting back from the provider:


{code=400, error_message=You must provide a client_secret, error_type=OAuthException}

Also here is the config of my resource:


<oauth:resource id="instagram"
bearerTokenMethod="query"
bearerTokenName="access_token"
accessTokenUri="https://api.instagram.com/oauth/access_token"
type="authorization_code"
clientId="XXX"
clientSecret="YYY"
userAuthorizationUri="https://api.instagram.com/oauth/authorize"/>

As you can see I'm trying to access the instagram api.

Any help will be appreciated.

Thx.

stoicflame
Mar 29th, 2011, 11:46 AM
Try specifying a form-based client authentication scheme on the resource (default is HTTP Basic Auth):



<oauth:resource id="instagram"
bearerTokenMethod="query"
bearerTokenName="access_token"
accessTokenUri="https://api.instagram.com/oauth/access_token"
type="authorization_code"
clientId="XXX"
clientSecret="YYY"
userAuthorizationUri="https://api.instagram.com/oauth/authorize"
clientAuthenticationScheme="form"/>

bouzafr
Mar 29th, 2011, 10:09 PM
That did the trick!!!

Thank you so much.