tags:

views:

504

answers:

4

Hey,

My problem is I get error while trying to get request token from Yahoo. The error says Im missing oauth_callback parameter and yes I miss it because I dont need it. Ive read I need to set it to "oob" value if I dont want to use it(desktop app). And I did that but to no avail. If I set it to null the same happens. Im using OAuth for java: http://oauth.googlecode.com/svn/code/java/core/

OAuthServiceProvider serviceProvider = new OAuthServiceProvider("https://api.login.yahoo.com/oauth/v2/get_request_token",
                                                                        "https://api.login.yahoo.com/oauth/v2/request_auth",
                                                                        "https://api.login.yahoo.com/oauth/v2/get_token");
OAuthConsumer consumer = new OAuthConsumer("oob", consumerKey, consumerSecret, serviceProvider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
OAuthClient client = new OAuthClient(new HttpClient4());
OAuthMessage response = client.getRequestTokenResponse(accessor, OAuthMessage.POST, null);
System.out.println(response.getBodyAsStream());
A: 

Have you tried using Scribe?

I also had problems with OAuth java libs so I developed that one. It's pretty much cross provider and better documented than the one you're using.

If it does not work with Yahoo you can easily extend it creating your own Provider

Hope that helps!

Pablo Fernandez
A: 

I haven't used that library, but it looks like it isn't properly handling the callback URL. Since OAuth 1.0a (http://oauth.net/advisories/2009-1/ and http://oauth.net/core/1.0a/), the callback URL needs to be sent in the first call to get the request token (not in the client-side call to authorise it), and it seems that this library hasn't been updated to do this (at least from looking at the code). I assume that Yahoo requires the parameter to be there.

paulcm
A: 

there is a problem in the java OAuthMassage class, I resolved it by adding to addRequiredParameters method thie line if (pMap.get(OAuth.OAUTH_CALLBACK) == null) { addParameter(OAuth.OAUTH_CALLBACK, consumer.callbackURL); } if you still have this problem I can help you: [email protected]

A: 

Not sure if the original problem was ever solved, but wanted to point to a new Java OAuth SDK that Yahoo released last week:
http://developer.yahoo.net/blog/archives/2010/07/yos_sdk_for_java.html

Developers trying to access Yahoo's services via OAuth with Java may find parts of this SDK helpful.

BrianC