EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
567 stars 629 forks source link

ios sign-in sso does't work #585

Open LeoProk opened 5 years ago

LeoProk commented 5 years ago

Hello When i try log in on IOS i don't see any of my google accounts and it only give me option to sign in with new user (it works fine on android). I also don't get the "App" wants to use "google.com" to sign in my log in:

window.plugins.googleplus.login( {}, res => { this.fireAuth.auth.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(res.idToken)); }, function (msg) { } ); }

I have tried to look around for answer but couldn't find anything close Any help is welcome Thanks

guylando commented 5 years ago

+1 same thing in ios I don't see any of my google accounts

guylando commented 5 years ago

I am guessing that this happens because the ios sdk used is too old. UPDATE: This guess is wrong. related: https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/445 Google sdk moved to SFAuthenticationSession in 9-2017 in version 4.1.0 of the ios sdk: https://developers.google.com/identity/sign-in/ios/release#2017-09-05_--_v410 But the sdk here is 4.0.0 was last updated in Sep 12, 2016 https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/276#issuecomment-246472635: https://github.com/EddyVerbruggen/cordova-plugin-googleplus/commit/5bfe6b79d0c11819f96e56aea0265826ca1a33ae

@EddyVerbruggen The google ios sdk haven't been updated for 3 years, any plans on updating it? Seems like something that could be done in several minutes

guylando commented 5 years ago

Same problem reported more than half a year ago: https://stackoverflow.com/questions/51557817/how-to-get-google-accounts-chooser-in-ionic-3-ios

Might be related: https://github.com/openid/AppAuth-iOS/issues/186 https://stackoverflow.com/questions/46569570/sfauthenticationsession-isnt-sharing-cookies-on-the-real-devices https://stackoverflow.com/questions/49888414/google-sso-with-3rd-party-apps-broken-on-ios-11 https://github.com/openid/AppAuth-iOS/issues/227 https://stackoverflow.com/questions/45080031/third-party-sign-in-for-ios11-gidsigninbutton

Logout bug and workaround (of SFAuthenticationSession): https://github.com/googlesamples/google-services/issues/357 https://stackoverflow.com/questions/49256119/sign-in-with-google-prevents-the-user-to-sign-in-again-with-different-account https://github.com/googlesamples/google-services/issues/326

I don't know where we are supposed to ask google support for help so I asked in the closest thing to that, here: https://github.com/googlesamples/google-services/issues/403

guylando commented 5 years ago

@LeoProk Can you modify issue title to something like: "ios sign-in sso does't work"?

guylando commented 5 years ago

I found out the problem of why account is not shown in accounts chooser (at least after upgrading the ios sdk to SFAuthenticationSession, I don't know if it happened from same reason before upgrade): The google sso authentication accounts are saved in safari data and if you clear safari cache then the accounts are removed. This can be easily reproduced by logging in, in one app (such as yelp, tripadvisor and others) and then you WILL see accounts in other apps on google login. Then clean safari cache and offline data and then you will not see the accounts in other apps on google login. Facebook solved it using custom scheme redirect in a "open in app" button displayed in the SFAuthenticationSession.

LeoProk commented 5 years ago

@guylando I have tried to use the ios google login button with swift and it works fine. the plugin uses the same code to log in so no idea whats wrong

guylando commented 5 years ago

@LeoProk you mean you used swift instead of this plugin? did you try on ios 12.1.4? to reproduce try the following:

  1. Login with google account in another third party app like yelp or trip advisor
  2. Then delete safari cookies and offline data
  3. Then try to login with your ios google login button in your app
  4. You will not see the google account in the account chooser, it will ask you to enter credentials again

If you do the same without step 2 then in step 4 you WILL see the google account in the account chooser.

This problem is not related to this plugin, its the way new ios SFAuthenticationSession works.

If you can't reproduce try upgrade your cordova-plugin-googleplus plugin to this version: https://github.com/guylando/cordova-plugin-googleplus (installing using github url instead of npm). Because currently the plugin uses a 3 years old google ios sdk which doesn't use SFAuthenticationSession and which might have other problems. I reproduced this consistent behavior after upgrading the google ios sdk to one which uses SFAuthenticationSession.

KrishnaChaitanyaAmjuri commented 5 years ago

When the user logs out, if we call GIDSignIn.sharedInstance()?.signOut(). Next time, then the email selection screen will appear.

It works for us