Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1301] SSO for facebook does not work on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-04-17T06:14:21.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules
LabelsSSO, android, facebook
ReporterArman Masoudi
AssigneeRitu Agrawal
Created2014-04-08T13:14:47.000+0000
Updated2016-03-08T07:37:42.000+0000

Description

I am building an app for iOS and Android. To login to Facebook I'm using the Titanium Module. In iOS, all forms of Facebook login works fine. In Android, when I execute the fb.authorize() for the first time, the log in event from Facebook is fired with no problem at all. But if I log out and then try to authorize again(at this point my app's permissions have been already accepted so in theory it should fire the login event) I get the following error on logcat: [ERROR] : FacebookModule: (main) [32951,33668] LoginDialogListener onFacebookError: Invalid access token. [ERROR] : FacebookModule: com.facebook.android.FacebookError: Invalid access token. [ERROR] : FacebookModule: at com.facebook.android.Facebook.onSessionCallback(Facebook.java:433) [ERROR] : FacebookModule: at com.facebook.android.Facebook.access$000(Facebook.java:97) [ERROR] : FacebookModule: at com.facebook.android.Facebook$2.call(Facebook.java:379) [ERROR] : FacebookModule: at com.facebook.Session$3$1.run(Session.java:1239) [ERROR] : FacebookModule: at android.os.Handler.handleCallback(Handler.java:615) [ERROR] : FacebookModule: at android.os.Handler.dispatchMessage(Handler.java:92) [ERROR] : FacebookModule: at android.os.Looper.loop(Looper.java:153) [ERROR] : FacebookModule: at android.app.ActivityThread.main(ActivityThread.java:5042) [ERROR] : FacebookModule: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : FacebookModule: at java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : FacebookModule: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821) [ERROR] : FacebookModule: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) [ERROR] : FacebookModule: at dalvik.system.NativeStart.main(Native Method) [ERROR] : FacebookModule: (main) [108,33776] onAuthFail: Invalid access token. if I manually remove the app permissions in the test users profile, I can again call fb.authorize() successfully and trigger the fb.login event. but again after logout, same problem raises.

Attachments

FileDateSize
Test-FB-SSO-Android.zip2014-04-08T22:16:39.000+00002464656

Comments

  1. Ritu Agrawal 2014-04-08

    This issue seems to be a duplicate of TIMODOPEN-377. Can you please confirm? If not, we need a simple runnable test case to reproduce this issue.
  2. Arman Masoudi 2014-04-08

    Hi Ritu, No, this is not the same problem as TIMODOPEN-377. The other case is an issue experienced in iOS. with this ticket, iOS works fine; Running the app in Android generate the issue I explained above. How to reproduce: 1. Import the test project uploaded for this case (TEst-FB-SSO-Android.zip) - update the facebook app id in the tiapp.xml and applicationwindow.js 2. Run the project and install the app in an Android device (I have tested API 4.1) - please note, you need to have the FB app installed as this problem is related to SSO (normal sign in with Facebook works fine) 3. Click on the facebook login button. If you have previously authorized the user in the nominated facebook app, you'll see the above error straight away. but if you've never authorized the test user with the nominated app for the set permissions, you'll be able to login successfully once. When you logout and try to login again, you'll see the above error. Let me know if you have any question. Regards, Arman
  3. Ritu Agrawal 2014-04-09

    Thanks for the test case. I noticed that you are setting fb.forceDialogAuth = false; Can you please try commenting it out and see if you are able to login successfully after logging out from Facebook? Related Q&A topic: https://developer.appcelerator.com/question/141517/titaniumfacebookforcedialogauth-not-reopening-my-app
  4. Arman Masoudi 2014-04-09

    Hi Ritu, The default value of fb.forceDialogAuth is TRUE which means If I dont set the value to false, it will not do SSO. As mentioned above, if I dont use SSO, everything works fine. But I need to implement SSO (which is done by setting the value of fb.forceDialogAuth to TRUE); the SSO works fine with iOS and according to the documentations it should also works fine with Android which is not the case here. When I set the value of fb.forceDialogAuth to FALSE to force SSO, I get the above error on Android. Where you able to reproduce the issue? Thanks Arman
  5. Ritu Agrawal 2014-04-10

    I have not been able to reproduce this error or issue with this test case or Kitchen Sink example. Setting fb.forceDialogAuth to False works fine for me on Samsung Galaxy device. Can you try KitchenSink example with this property set to False and see if you can reproduce this issue? KitchenSink => MASHUPS => Facebook => Login/Logout
  6. deepakpardeshi 2014-04-11

    Hi i am also facing same issue on my android project. SSO keeping fb.forceDialogAuth to Fasle.Only first time when fb app is not authorised i can able to log in, after wards i can not log in get following error. FacebookModule: (main) [5164,192826] LoginDialogListener onFacebookError: Invalid access token. [ERROR] : FacebookModule: com.facebook.android.FacebookError: Invalid access token. [ERROR] : FacebookModule: at com.facebook.android.Facebook.onSessionCallback(Facebook.java:433) [ERROR] : FacebookModule: at com.facebook.android.Facebook.access$000(Facebook.java:97) [ERROR] : FacebookModule: at com.facebook.android.Facebook$2.call(Facebook.java:379) [ERROR] : FacebookModule: at com.facebook.Session$3$1.run(Session.java:1239) [ERROR] : FacebookModule: at android.os.Handler.handleCallback(Handler.java:615) [ERROR] : FacebookModule: at android.os.Handler.dispatchMessage(Handler.java:92) [ERROR] : FacebookModule: at android.os.Looper.loop(Looper.java:137) [ERROR] : FacebookModule: at android.app.ActivityThread.main(ActivityThread.java:4960) [ERROR] : FacebookModule: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : FacebookModule: at java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : FacebookModule: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) [ERROR] : FacebookModule: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) [ERROR] : FacebookModule: at dalvik.system.NativeStart.main(Native Method) [ERROR] : FacebookModule: (main) [4,192830] onAuthFail: Invalid access token.
  7. Arman Masoudi 2014-04-11

    For me the problem was my hash key (which you have to enter in the configuration of your facebook app). I finally managed to generate the correct dev hash key using the following command: keytool -exportcert -alias tidev -keystore ~/Library/"Application Support"/Titanium/mobilesdk/osx/3.2.2.GA/android/dev_keystore -s torepass tirocks | openssl sha1 -binary | openssl base64 Ritu, Thank you for your help. I dont experience this issue anymore.
  8. deepakpardeshi 2014-04-11

    Hi arman i created hash key using above command but still getting same error can you please help me. what is -storepass tirocks in above command didn't get that.
  9. Arman Masoudi 2014-04-11

    I have no idea about the components of the command. What password did you enter? you must enter 'android'
  10. Ritu Agrawal 2014-04-17

    Resolving this ticket as the reporter confirmed that it was an issue with his hash key.

JSON Source