Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 views
in Technique[技术] by (71.8m points)

android - 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...