iosauthenticationgoogle-signinin-house-distribution

Logging into Google Services without using Google Sign-In Button


I'm working on an in-house app where I need to authorize the user with Google (Gsuite really) so they can be logged into Google web apps (Mail and Drive specifically). I also need to grab the username and password at that time so they can also be signed into other in-house services. They'll be asked to sign in at each launch. I'd like it to be a seamless experience where they don't really see the Google branding at all (until they load the web interfaces of course).

I know I can use the Google Sign-In SDK for iOS for the Google part, but it seems like that requires using their button and web view and I won't be able to grab the login info.

What's my best option here?

FYI, This will be my first real app distributed to and used by anybody other than myself. So take that for what it's worth.


Solution

  • As shown here at the Google developers link, if you scroll down to number 5:

    If you want to customize the button, do the following: In your view controller, declare the sign-in button as a property. @IBOutlet weak var signInButton: GIDSignInButton! Connect the button to the signInButton property you just declared. Customize the button by setting the properties of the GIDSignInButton object.

    So what you can do is create your own sign in button made to look the way you want and set it as a property. Or you could set an @IBAction and make it call the GIDSignIn.sharedInstance().signIn() method. Keep in mind you will still have to implement GIDSignInDelegate and GIDSignInUIDelegate.

    Also, it sounds like you want to make a custom auth flow (enter email and password regardless of Google account or not). In that case you might consider using Firebase Custom Auth. Hope this helped, thanks :)