Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSO (Singe Sign-On) not working when Facebook app is installed on device

I am developing an Android app that integrates with facebook. The app works perfectly fine when I set LoginButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO).

The problem arises when I try to use SSO. I get the error below. I used to get a similar error when I used an incorrect keyhash; this is not the case anymore because the Webview log in works fine. What is event more surprising is that the Android app works if the app is installed in FB. For example, I am the app manager therefore it gets installed in my facebook profile by default, but when I try with another fb account that doesn't have the app installed it doesn't work. When I attempt to log in the error below appears and I get a dialog telling me that basic permissions will be granted, but in reality I do not even get basic permissions.

I have submitted the app for review in order to get it shown on the App Center. When I do that, the dialog shows a checkbox where I acknowledge that my app uses SSO. Does facebook need to approve my app before I can use SSO (if so, this doesn't make sense)

I have spent hours trying to solve this, and I can't find the solution. Please help.

08-24 01:39:16.058: W/Bundle(21880): Key com.facebook.platform.protocol.PROTOCOL_VERSION expected String but value was a java.lang.Integer.  The default value <null> was returned.
08-24 01:39:16.068: W/Bundle(21880): Attempt to cast generated internal exception:
08-24 01:39:16.068: W/Bundle(21880): java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
08-24 01:39:16.068: W/Bundle(21880):    at android.os.Bundle.getString(Bundle.java:1069)
08-24 01:39:16.068: W/Bundle(21880):    at android.content.Intent.getStringExtra(Intent.java:4350)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.AuthorizationClient$KatanaLoginDialogAuthHandler.tryAuthorize(AuthorizationClient.java:821)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.AuthorizationClient.tryCurrentHandler(AuthorizationClient.java:272)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.AuthorizationClient.tryNextHandler(AuthorizationClient.java:238)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.AuthorizationClient$GetTokenAuthHandler.getTokenCompleted(AuthorizationClient.java:772)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.AuthorizationClient$GetTokenAuthHandler$1.completed(AuthorizationClient.java:731)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.internal.PlatformServiceClient.callback(PlatformServiceClient.java:144)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.internal.PlatformServiceClient.handleMessage(PlatformServiceClient.java:128)
08-24 01:39:16.068: W/Bundle(21880):    at com.facebook.internal.PlatformServiceClient$1.handleMessage(PlatformServiceClient.java:54)
08-24 01:39:16.068: W/Bundle(21880):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 01:39:16.068: W/Bundle(21880):    at android.os.Looper.loop(Looper.java:137)
08-24 01:39:16.068: W/Bundle(21880):    at android.app.ActivityThread.main(ActivityThread.java:5227)
08-24 01:39:16.068: W/Bundle(21880):    at java.lang.reflect.Method.invokeNative(Native Method)
08-24 01:39:16.068: W/Bundle(21880):    at java.lang.reflect.Method.invoke(Method.java:511)
08-24 01:39:16.068: W/Bundle(21880):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-24 01:39:16.068: W/Bundle(21880):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-24 01:39:16.068: W/Bundle(21880):    at dalvik.system.NativeStart.main(Native Method)
like image 718
Emmanuel Avatar asked Aug 24 '13 06:08

Emmanuel


People also ask

Does Facebook use single sign on?

Facebook's single sign-on, announced today, will replace Facebook Connect to log you onto partner sites and services using your Facebook credentials.

Why can'ti log into Facebook on my phone?

If you're having trouble logging into your Facebook account from your Facebook app: Make sure that you have the latest version of the Facebook app, or delete the app and then reinstall it. Try logging in from a mobile browser (example: Safari, Chrome).


1 Answers

I had a similar logcat output and found out that it was related to incorrectness in the FB 3.5 source code. As described above it´s on line 821 in AuthorizationClient.java. There should be getIntExtra instead of getStringExtra. Download the source from github and change

intent.getStringExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION));

to

""+intent.getIntExtra(NativeProtocol.EXTRA_PROTOCOL_VERSION, 0));
like image 152
hakanostrom Avatar answered Oct 31 '22 14:10

hakanostrom