google-signin icon indicating copy to clipboard operation
google-signin copied to clipboard

Support multiple accounts simultaneously

Open derabbink opened this issue 7 years ago • 7 comments

This is a feature request. Since GoogleSignin is exported as a singleton, developers cannot create separate - differently configured - instances for use in an app that is signed into multiple accounts simultaneously.

This is relevant for using Google APIs on behalf of multiple Google accounts simultaneously, where the APIs operate on resources that cannot be shared between Google accounts. Examples of such APIs are those that are part of GSuite/Google Apps for Business APIs, and which are only available to domain admins.

derabbink avatar Feb 24 '17 22:02 derabbink

+1

xuezhma avatar Aug 31 '17 21:08 xuezhma

This is indeed very interesting feature. Please feel free to send PR to contribute.

AndreiCalazans avatar May 27 '18 12:05 AndreiCalazans

~I believe we will get to this soon.~ I don't have time and need for this, contributions are welcome (please open an issue to discuss first).

vonovak avatar Jun 23 '18 20:06 vonovak

Has there been any progress with this feature?

casey-budee avatar Nov 13 '18 23:11 casey-budee

No one has submitted any PRs for it @casey-budee 😢

AndreiCalazans avatar Nov 14 '18 10:11 AndreiCalazans

Hey amazing react-native-google-signin people (and I mean that, I'm using this library, I followed the instructions and it worked, that's amazing)

Anyone have a sketch of what would be required here? Or some example code (maybe other language from flutter or pure android or whatever) where they handle it?

I'm not asking anyone to do a bunch of work here, just if anyone that has familiarity with the code and thought through it before wants to brain dump, it might be the baton I or someone else could pick up to then propose a PR

Cheers

mikehardy avatar Dec 13 '19 03:12 mikehardy

hi @mikehardy thanks for the kind words.

As for how to handle multiple users - the JS apis mirror the native apis, meaning the native apis also do not give a strong hint that multiple users are supported (eg. there is no users array in the native apis, there is just currentUser). So the next possibility is to look at the native classes that provide sign in functionality, maybe we can have multiple instances of those and switch between them?

On android this is done via GoogleSignInClient here and is should be possible to have multiple instances of that class. But on iOS, there is the [GIDSignIn sharedInstance] call here and to me that sounds like a singleton so there is (afaik?) no way to create multiple instances of anything here. So, to sum up, without extra research I'm not sure how to do this right.

One possible way to support multiple users (which may not work for everybody though) would be to call signOut before you call signIn for the next user, so for user it'd look as if multiple users were supported where in fact only one would be handled at a time. If the second one cancels the sign in process though, that might be an issue as no user will be logged in at that point.

I don't need this, but if someone does, please get in touch and you can hire me.

To respond to the first post, It's true the exported JS class is a singleton, but that is not the limiting factor here.

some resources:

SO - ios - it may be possible to rewrite this library to use GTMAppAuth SO - android

vonovak avatar Dec 13 '19 08:12 vonovak