Javier Manzano Javier Manzano - 1 year ago 129
Java Question

Oauth problems with Scribe

I'm using scribe for making an app that has oauth support. I didn't found problems With Twitter, but when using facebook I have problems...

This is the code that works on twitter oauth

OAuthService s = /* ... Facebook oauth init ... */
final Token requestToken = s.getRequestToken();
final String authURL = s.getAuthorizationUrl(requestToken);

It gives me an error at the second line:

12-20 10:01:31.475: E/AndroidRuntime(5405): java.lang.UnsupportedOperationException: Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there
12-20 10:01:31.475: E/AndroidRuntime(5405): at org.scribe.oauth.OAuth20ServiceImpl.getRequestToken(OAuth20ServiceImpl.java:45)

I know that it says that I might use getAuthorizationUrl... But I have to pass a requestToken...

Could you please help me?

It would be helpful any example with Scribe and Facebook


PS: Same problem with Windows Live ! =(


I have been looking at the source code of the Scribe library and I found something


Here we can see that I can call the getAuthorizationUrl(...) with null parameter because it doesn't use it.... But I think the prioblem now is that the config isn't filled...

here is how I initialize facebook service:

new ServiceBuilder()

Is this correct?


Answer Source
private static final Token EMPTY_TOKEN = null;

OAuthService service = new ServiceBuilder()
 String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);

All you now need to redirect user to this URL and let him verify them self to get code from facebok.

There are a good amount of example with very good documentation for almost all major Oath system

here is for Facebook


For all major providers Scribe Example Directory


After looking at the discussion my suggestion is to get a full understanding about Oauth1 and Oauth2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download