AdamBrodzinski / meteor-phonegap-oauth

Fixes how Meteor handles OAuth popups on PhoneGap/fullscreen
MIT License
33 stars 7 forks source link

Having issue with Google and meteor-cordova-loader #12

Open adamgins opened 10 years ago

adamgins commented 10 years ago

Thanks for the meteor-phonegap-oauth

I originally posted this issue with meteor-cordova-loader but recommendation was to post it here:

#20

I am using: Meteor 0.8.3 with Google for authentication. I installed " mrt add phonegap-oauth"

I seem to have tricked it to work, but after stopping and starting my Meteor server it went all haywire.

Screen 1

screen shot 2014-08-07 at 9 32 29 am

Screen 2

screen shot 2014-08-07 at 9 28 41 am

It seems to get stuck in some loop between screen 1 and screen 2. Before screen 2 flashes up, I do see the Google authentication screen flashup (see Screen 3 below)... but it's replaced with screen 2 too quickly to actually do anything.

Screen 3:

screen shot 2014-08-07 at 9 42 45 am

here's what I see on my Meteor terminal log:

Adams-MacBook-Pro-2:buzzy adamginsburg$ mrt --settings settings.json

Stand back while Meteorite does its thing

Done installing smart packages

Ok, everything's ready. Here comes Meteor!

warning: still trying to confirm logout with www.meteor.com
[[[[[ ~/Documents/Development/buzzy ]]]]]

=> Started proxy.
Exception in stream connect callback: Error: Got open from inactive client
    at _.extend._onConnect (packages/livedata/stream_client_nodejs.js:57)
    at packages/livedata/stream_client_nodejs.js:138
    at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108)
=> Started MongoDB.     
I20140807-08:51:45.648(10)? => GraphicsMagick found
I20140807-08:51:45.833(10)?  Meteor [cordova] Starting Cordova Asset Compiler...
I20140807-08:51:45.834(10)?  Meteor [cordova] Enabled Platforms:  : ios
I20140807-08:51:45.834(10)?  Meteor [cordova] Cordova Project Path: : /Users/adamginsburg/Documents/Development/buzzy/.cordova
I20140807-08:51:45.834(10)?  Meteor [cordova] cordova-loader started in development mode.
I20140807-08:51:45.834(10)?  Meteor [cordova] Adding ios Cordova file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/cordova.js
I20140807-08:51:45.834(10)?  Meteor [cordova] Adding ios Cordova file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/cordova_plugins.js
I20140807-08:51:45.837(10)? ** You are using the appcache package but the total size of the
I20140807-08:51:45.837(10)? ** cached resources is 13.1MB.
I20140807-08:51:45.840(10)? **
I20140807-08:51:45.840(10)? ** This is over the recommended maximum of 5 MB and may break your
I20140807-08:51:45.840(10)? ** app in some browsers! See http://docs.meteor.com/#appcache
I20140807-08:51:45.840(10)? ** for more information and fixes.
I20140807-08:51:45.840(10)? 
I20140807-08:51:45.937(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.device/www/device.js
I20140807-08:51:45.937(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.splashscreen/www/splashscreen.js
I20140807-08:51:45.937(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.dialogs/www/notification.js
I20140807-08:51:45.937(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/com.ionic.keyboard/www/keyboard.js
I20140807-08:51:45.938(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/com.phonegap.plugins.PushPlugin/www/PushNotification.js
I20140807-08:51:45.950(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.geolocation/www/Coordinates.js
I20140807-08:51:45.950(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.geolocation/www/PositionError.js
I20140807-08:51:45.951(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.geolocation/www/Position.js
I20140807-08:51:45.951(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.geolocation/www/geolocation.js
I20140807-08:51:45.955(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/com.oauthio.plugins.oauthio/www/dist/oauth.js
I20140807-08:51:45.956(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/contacts.js
I20140807-08:51:45.956(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/Contact.js
I20140807-08:51:45.956(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactAddress.js
I20140807-08:51:45.974(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactError.js
I20140807-08:51:45.974(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactField.js
I20140807-08:51:45.974(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactFindOptions.js
I20140807-08:51:45.975(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactName.js
I20140807-08:51:45.980(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactOrganization.js
I20140807-08:51:45.980(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ContactFieldType.js
I20140807-08:51:45.980(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ios/contacts.js
I20140807-08:51:45.980(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.contacts/www/ios/Contact.js
I20140807-08:51:45.998(10)?  Meteor [cordova] Adding ios plugin file : /Users/adamginsburg/Documents/Development/buzzy/.cordova/platforms/ios/www/plugins/org.apache.cordova.inappbrowser/www/inappbrowser.js
I20140807-08:51:46.788(10)?  Meteor [cordova] Saved packed Cordova file for production use. : /private/cordova/ios.js
=> Started your app.

=> App running at: http://localhost:3000/
I20140807-09:25:10.458(10)? search expression:/b2RbhWuXNMYnghy44/
I20140807-09:28:03.196(10)?  Meteor [cordova] Serving the cordova.js file to platform : ios
I20140807-09:28:06.345(10)? search expression:/b2RbhWuXNMYnghy44/
I20140807-09:28:33.406(10)? search expression:/null/
I20140807-09:32:12.251(10)?  Meteor [cordova] Serving the cordova.js file to platform : ios
I20140807-09:32:15.919(10)? search expression:/null/
I20140807-09:32:15.955(10)? search expression:/null/

After a few refreshes it showing Screen 3(above)

This is what was in the simulator log:

 Marker - 7 Aug 2014 9:42:29 am
Aug  7 09:42:34 Adams-MacBook-Pro-2.local Buzzy[99584] <Warning>: Setting the WebView's frame to {{0, 0}, {320, 524}}
Aug  7 09:42:41 --- last message repeated 1 time ---
Aug  7 09:42:41 Adams-MacBook-Pro-2.local Buzzy[99584] <Warning>: Warning: Attempt to dismiss from view controller <MainViewController: 0xb5174c0> while a presentation or dismiss is in progress!

After I click sign-in, I get, Screen 3 again.

When I click "Done" (bottom left), It takes me back to Screen 1.

BTW, it was all working and showing my Meteor app after login properly. I have no idea what I have done. I tried rolling back to a working version but this did not seem to help. I deleted the apps off the simulator and removed/added phonegap-oauth... I got it working again but it's really sporadic.

AdamBrodzinski commented 10 years ago

Hmmmm, I haven't ran into that yet. I haven't checked to see if Google login is working properly. You may want to checkout this issue to see if it's applicable with Google.

I had a blank page popping up for google login after the first one. I fixed it by
using the forceApprovalPrompt available in Accounts.loginWithMeteor(). It is 
now an extra button click for the user but it works reliably.

Perhaps @mikowals has some insight on this?

Some things to try

  1. trying the LinkedIn or Twitter OAuth. I haven't had a need to use Google's OAuth yet and I didn't have the time to add it in... it's possible there's something going wrong specifically with that.
  2. try making a brand new spike with just the device plugin and the minimum needed to make meteor-cordova-loader to work. Add in Meteor-Phonegap-Oauth and then add the Twitter Oauth package (and prob. accounts ui buttons for easy of testing). This combo is working great using MeteorRider... if it fails here it might be an issue with Meteor-Cordova-Loader (If so let me know and I'll try and look into integrating it). Once it's working well with Twitter, add in Google OAuth and see if the issue crops up again. If not, just keep slowly adding in plugins/packages until it breaks.

It's kind of a pain in the ass to spike and add everything back in but i've found it to be the fastest way to trace down the issue, especially with mobile web and Phonegap.

Hope this helps! Let me know how it works out either way

jperl commented 10 years ago

I would also try the latest master, 14d510e618fcdde7299d0bf86366aad5c9c42a1c may have fixed it.

adamgins commented 10 years ago

Thanks for the quick response.

just wondering if the following gives you any idea on what's happening?:

2014-08-07 14:58:37.070 Buzzy[18090:60b] Finished load of: http://localhost:3000/resources/
2014-08-07 14:58:45.498 Buzzy[18090:60b] Setting the WebView's frame to {{0, 0}, {320, 524}}
2014-08-07 14:58:45.499 Buzzy[18090:60b] THREAD WARNING: ['InAppBrowser'] took '17.028076' ms. Plugin should use a background thread.

I do have the following in my router.js:

Router.onBeforeAction(IR_BeforeHooks.isLoggedIn, {except: ['start']}); //need to come back and looks at this for documents
Router.onBeforeAction('loading');
Router.onBeforeAction(function() { clearErrors() });
Router.onAfterAction(IR_AfterHooks.isLoggedIn, {only: ['start']});

If I comment out the two "IR_AfterHooks.isLoggedIn," (1st and last lines) - it brings up the app (without user logged in, even if I try and login)... so I think it must be cycling around and not logging in for some reason. Hence the reason it was flashing up the login screen. The weird thing is I can't isolate it to my code. I tried deleting the app and reseting the Safari cache and it's just not working, so not sure how I got it to work before?

The other thing is when there server starts I see:

=> Started proxy.
Exception in stream connect callback: Error: Got open from inactive client
    at _.extend._onConnect (packages/livedata/stream_client_nodejs.js:57)
    at packages/livedata/stream_client_nodejs.js:138
    at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108)
=> Started MongoDB.     

Not sure if you know why this is happening? It only seems to happen when the server first starts up. If i crtl-c and restart it's not there:

=> Started proxy.
=> Started MongoDB.     

As for "forceApprovalPrompt available in Accounts.loginWithMeteor()" I think to try this out I have to move away from the {{>loginbuttons}} approach and go custom... it may take me some time as I'll be away for a couple of weeks from Sunday if I don't get to it.

I'll try out the other services... but the thing is it was working and Google oauth works fine in my browser app.

adamgins commented 10 years ago

@jperl thanks. How do I ensure I am using this version... will mrt remove/add ensure it? or mrt update?

adamgins commented 10 years ago

BTW there was a major change in

So I blitzed my meteor project and re-setup cordova-loader, I get to my sign-in page, then get prompted to give access to services, then get the same issue, ie the page is blank:

Aug  8 17:13:03 Adams-MacBook-Pro-2.local lsd[53111] <Warning>: LaunchServices: Currently 0 installed placeholders: (
    )
Aug  8 17:13:13 Adams-MacBook-Pro-2.local mstreamd[53101] <Notice>: (Note ) PS: Media stream daemon stopping.
Aug  8 17:13:13 Adams-MacBook-Pro-2.local mstreamd[53101] <Notice>: (Note ) AS: <MSIOSAlbumSharingDaemon: 0x3c2e1b0>: Shared Streams daemon has shut down.
Aug  8 17:13:13 Adams-MacBook-Pro-2.local mstreamd[53101] <Notice>: (Warn ) mstreamd: mstreamd shutting down.
Aug  8 17:13:44 Adams-MacBook-Pro-2.local Buzzy[53118] <Warning>: Resetting plugins due to page load.
Aug  8 17:13:48 Adams-MacBook-Pro-2.local Buzzy[53118] <Warning>: Finished load of: https://accounts.google.com/o/oauth2/auth?scope=email+profile+https://www.googleapis.com/auth/youtube&response_type=code&access_type=online&redirect_uri=http://localhost:3000/_oauth/google?close&approval_prompt=auto&state=iLlCluh0GzK4x2HodhJeAxDCq_0SVCHrHVkfkqAitKK&client_id=1090788978289-1ta1l80bu20vimn1ss7d2c68ckg059ab.apps.googleusercontent.com&hl=en-GB&from_login=1&as=-7b409491a52f2bc5&pageId=none
Aug  8 17:13:51 Adams-MacBook-Pro-2.local Buzzy[53118] <Warning>: Resetting plugins due to page load.
Aug  8 17:13:55 Adams-MacBook-Pro-2.local Buzzy[53118] <Warning>: Failed to load webpage with error: The operation couldn’t be completed. (NSURLErrorDomain error -999.)

I am out for 2 weeks from Sunday... so may get time to try twitter or other services. That said I suspect other folk may hit this.

adamgins commented 10 years ago

BTW, what's the diff between meteor-phonegap-oauth and phonegap-oauth the meteor-phonegap-oauth readme seems to refer to "phonegap-oauth"?

adamgins commented 10 years ago

Hi, back from vacation. I got things working with Twitter.. but still seems to be ab issue using Google for authentication.

AdamBrodzinski commented 10 years ago

I haven't tried Google OAuth in awhile, I'll try it again tonight with the latest.— Sent from Mailbox

On Tue, Aug 26, 2014 at 12:14 AM, adamgins notifications@github.com wrote:

Hi, back from vacation. I got things working with Twitter.. but still seems to be ab issue using Google for authentication.

Reply to this email directly or view it on GitHub: https://github.com/AdamBrodzinski/meteor-phonegap-oauth/issues/12#issuecomment-53373538