Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple accounts simultaneously #200

Open
derabbink opened this issue Feb 24, 2017 · 7 comments
Open

Support multiple accounts simultaneously #200

derabbink opened this issue Feb 24, 2017 · 7 comments

Comments

@derabbink
Copy link

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.

@xuezhma
Copy link

xuezhma commented Aug 31, 2017

+1

@AndreiCalazans
Copy link
Collaborator

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

@vonovak
Copy link
Member

vonovak commented Jun 23, 2018

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).

@casey-budee
Copy link

Has there been any progress with this feature?

@AndreiCalazans
Copy link
Collaborator

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

@mikehardy
Copy link

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

@vonovak
Copy link
Member

vonovak commented Dec 13, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants