Simple Login, Facebook & Phonegap/Cordova Issue

1,487 views
Skip to first unread message

Vishal Joshi

unread,
Jun 2, 2014, 9:42:28 PM6/2/14
to fireba...@googlegroups.com
I have followed all the recommendations and have got my facebook + simple login working awesome on my web test pages.  But now the same thing does not work in phonegap application (cordova 3.3.0) the token comes back but it gets redirected to a blank page https://auth.firebase.com/auth/_blank  with valid token (I can see it in browser tools & xCode) instead of getting redirected to my app. Has anyone faced this issue.  Any help will be much appreciated.

Vishal Joshi

unread,
Jun 3, 2014, 5:01:29 PM6/3/14
to fireba...@googlegroups.com

Rob DiMarco

unread,
Jun 3, 2014, 7:32:32 PM6/3/14
to fireba...@googlegroups.com
Hi Vishal -

Happy to help you get to the bottom of this issue. PhoneGap / Cordova can be tricky and there are some gotchas to be aware of:
  • The InAppBrowser plug-in must be included and enabled in your app
  • The phonegap.js or cordova.js client libraries must be included in your app

Depending upon the platform you're testing, there may be some gotchas with respect to session persistence due to varying browser cookie support on those platforms. Following this message, I'll ping you off-list and see if we can't get to the bottom of it.

Thanks -

Rob DiMarco
Engineer @ Firebase



On Mon, Jun 2, 2014 at 6:42 PM, Vishal Joshi <vishal...@gmail.com> wrote:
I have followed all the recommendations and have got my facebook + simple login working awesome on my web test pages.  But now the same thing does not work in phonegap application (cordova 3.3.0) the token comes back but it gets redirected to a blank page https://auth.firebase.com/auth/_blank  with valid token (I can see it in browser tools & xCode) instead of getting redirected to my app. Has anyone faced this issue.  Any help will be much appreciated.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rob DiMarco

unread,
Jun 4, 2014, 2:10:10 PM6/4/14
to fireba...@googlegroups.com
Is that URL opening in the main frame, or a new browser window / InAppBrowser?


--

Gordon Sun

unread,
Jun 26, 2014, 2:37:45 AM6/26/14
to fireba...@googlegroups.com

I have a similar problem. The page I end up with is: (Looks like in the main frame but not a InAppBrowser)

014-06-25 23:04:42.299 HelloWorld[17797:60b] Finished load of:

https://auth.firebase.com/blank/page.html#&token=%22eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0MDM4NDkwODIsInYiOjAsImQiOnsiaWQiOiI4MDIzMjgzNDY0NTE2MjQiLCJ1aWQiOiJmYWNlYm9vazo4MDIzMjgzNDY0NTE2MjQiLCJwcm92aWRlciI6ImZhY2Vib29rIn0sImlhdCI6MTQwMzc2MjY4MX0.18DVN2Vs3U0uth4ylR0_9YZ6Atk3ZjFJPNzm0xd7Eeg%22&user=%7B%22id%22%3A%22802328346451624%22%2C%22uid%22%3A%22facebook%3A802328346451624%22%2C%22displayName%22%3A%22Gordon%20Sun%22%2C%22provider%22%3A%22facebook%22%2C%22sessionKey%22%3A%2289639cf2d83191dd32f57077e5156d8f%22%2C%22thirdPartyUserData%22%3A%7B%22id%22%3A%22802328346451624%22%2C%22email%22%3A%22sunshineo%40gmail.com%22%2C%22first_name%22%3A%22Gordon%22%2C%22gender%22%3A%22male%22%2C%22languages%22%3A%5B%7B%22id%22%3A%22103088979730830%22%2C%22name%22%3A%22Mandarin%20Chinese%22%7D%2C%7B%22id%22%3A%22106059522759137%22%2C%22name%22%3A%22English%22%7D%5D%2C%22last_name%22%3A%22Sun%22%2C%22link%22%3A%22https%3A%2F%2Fwww.facebook.com%2Fapp_scoped_user_id%2F802328346451624%2F%22%2C%22locale%22%3A%22en_US%22%2C%22name%22%3A%22Gordon%20Sun%22%2C%22timezone%22%3A-7%2C%22updated_time%22%3A%222014-01-02T03%3A21%3A00%2B0000%22%2C%22verified%22%3Atrue%7D%2C%22accessToken%22%3A%22CAAVGJVxqwG0BACF5mVrvuCzJzi4Fd0DZCc8DjrOhajGqJZBsvGh4SU2QSv4UZB5PU3k3xZAyMaTxZCyMLUDHdI1UPhffh9cP7Uz0XSJpZCCBlWUQ2lontaPdcTZCUUZB9UTuifJZBt384SnBHWZC28qAmi74xTPVjZAQmU1ZBG9vMWG1gS0GX09oCqGY%22%7D

The token part is proper with my information but I stuck with the blank white page. I got no callback.

Jacob Wenger

unread,
Jun 26, 2014, 5:18:07 PM6/26/14
to fireba...@googlegroups.com
Hi Gordon,

Have you done all of the things Rob suggested a few posts back? Also, make sure you are using the latest version of Firebase Simple Login. The current version as of this message is 1.6.1. Rob made some changes in version 1.6.0 which fixed a bunch of Cordova issues. Give that a try and if you are still having issues, message this group again.

Jacob

James Nonamaker

unread,
Jul 15, 2014, 12:46:43 PM7/15/14
to fireba...@googlegroups.com
Hi Rob,
I was having a similar issue.  I went through your suggestions and have arrived at a different outcome.  

I am using the command line iOS emulator and the XCode emulator with the same results.  I no longer receive the blank html page which is good.  However, these two behaviors are occuring:

1.  When I log-in with Facebook it automatically logs me in without re-directing me to Facebook.  There is a temporary blank modal, it disappears and I'm logged in.  This occurs even after I have logged out of the app, the app behaves as expected when logged out, and I log back in with FB.  
2.  The second behavior is when I log in with Twitter.  It will bring me to Twitter in the phone, I log-in, and it gives me "error: an unknown error has occurred" in the error log.  It then redirects me to the login page of my mobile app.  I have ensured my username and password works with twitter in the browser.      

I am working with Ionic/I have ensured I have SimpleLogin 1.6.1.  I have put the following lines in all of my config xml files:

<access origin="*" />
<access origin="*.firebaseio.*" />
<access origin="https://auth.firebase.com" />

I have installed the inApp browser plug-in; it is listed in my project's plug-in folder.  Cordova.js is included in my project's index.html.  However, it will be 404 until production according to Ionic.  

I surmise that I am facing what you reference when you say, "Depending upon the platform you're testing, there may be some gotchas with respect to session persistence due to varying browser cookie support on those platforms."  If you could help it would be greatly appreciated.  I'm in a bit of a time crunch to get this working as soon as possible.  Thank you!

Warmly,
James

James Nonamaker

unread,
Jul 15, 2014, 1:06:59 PM7/15/14
to fireba...@googlegroups.com
Rob,
I forgot to mention the app works great and as expected in the non-mobile browser.
James

Jacob Wenger

unread,
Jul 15, 2014, 1:23:52 PM7/15/14
to fireba...@googlegroups.com
Hey James,

Rob is out of the country so I've got control of the keys to Simple Login at the moment.

Using Simple Login with Cordova is definitely a tricky thing with lots of gotchas. I have been working through this myself over the past couple days. I found a definite bug in our code which I'm hoping to have resolved by shipping Simple Login 1.6.2 by the end of today. I have seen this bug crop up with the Twitter auth so that is probably the issue you are seeing. There is no work around for you until I actually push 1.6.2.

I'm going to put together some step-by-step instructions of how to get Simple Login working with Ionic/PhoneGap. These instructions have been sorely missing from our docs. You aren't the only one to run into issues with this recently.

I understand you are on a time crunch and am working to resolve these issues as fast as possible. I will post here with those instructions as soon as I have them (within a day or two).

Jacob

James Nonamaker

unread,
Jul 15, 2014, 2:03:55 PM7/15/14
to fireba...@googlegroups.com
Hi Jacob,
Thank you for the quick reply.  This is great news.  My timeline is the end of the week so this should work out well for me.  I do have one question that may be addressed in 1.6.2 but perhaps has a simpler answer.  

With regard to my first undesired behavior dealing with FB.  My browser actually does this as well in a normal Chrome session.  However, when I move to a new Incognito window the app works as desired.  Therefore, I am guessing this is the same issue that is happening with the emulator.  The emulator like a normal Chrome browser session is caching my login information to point that I cannot truly log out, even if the app is initially functioning in a logged out state.  Is there a way to ensure the emulator is working from a blank slate similar to a new incognito browser session?  Thanks for all the support. 

Warmly,
James  

Vishal Joshi

unread,
Jul 15, 2014, 4:13:55 PM7/15/14
to fireba...@googlegroups.com
I faced similar problem when I was getting this to work (i.e blank page + auto-login issue).  The problem really is that facebook stores its own cookies which are checked before user is formally redirected to login page.  These cookies cannot be cleared unless you write explicit code to do so.  This happens coz of "remember me" option which is only logical to use :-)  
Therefore even though firebase logged out  the cookie in the browser is still alive for next 30 days and unless you don't delete the app you will keep getting logged in after seeing blank page momentarily.  Here is the code I wrote in my log-out method hopefully it helps:

                       if(window.cookies){
window.cookies.clear(function() {
   console.log('Cookies cleared!');
});
}

window.cookie is object populated by cordova plugin which you need to install in your app.  You can find it at https://github.com/bez4pieci/Phonegap-Cookies-Plugin
HTH

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/wUkmgt6XMoU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

Jacob Wenger

unread,
Jul 15, 2014, 4:20:28 PM7/15/14
to fireba...@googlegroups.com
Hey James,

I agree that what you are seeing is not ideal behavior for mobile and can put you in a really bad place where you cannot logout. The behavior is somewhat expected on desktop though. If you log into Facebook through a Facebook-connected app, Facebook then logs you in on that device. So if you then logout of the app, you are still technically logged in to Facebook. If you navigate to Facebook, you will be logged in. Makes sense.

On mobile, this is a little trickier because each app has its own context. If I log into Facebook on App A, I won't be logged in on App B. (Unless I'm logged into Facebook through my iPhone itself, which is another topic.) Anyway, Facebook is essentially storing cookies saying who is logged into App A. So even after Firebase Simple Login logs you out of your app, Facebook still thinks you are logged in. Therefore, when Firebase Simple Login goes to connect to Facebook, we get the okay from them that someone is already logged in. I agree that this is a bit odd and makes it such that you cannot actually log out of the app.

I'm investigating how we can fix this from our end, but a workaround that just worked for me is to use this PhoneGap cookies plugin on GitHub. The command line statement on GitHub didn't work for me, but this one did:


Then, just add it to your app's JavaScript like so:

 if(window.cookies){
  window.cookies.clear(function() {
  console.log('Cookies cleared!');
  });
}

We will work on getting this to work out of the box with Simple Login. Until then, use this workaround.

Jacob

James Nonamaker

unread,
Jul 15, 2014, 10:25:38 PM7/15/14
to fireba...@googlegroups.com
Jake and Vishal,

Thanks for the help.  My app is working as expected in the emulator with FaceBook login now.  I really appreciate the timely assistance.

Warmly,
James
Reply all
Reply to author
Forward
0 new messages