Google Sign In Plugin

Recently Google disallowed sign though webviews. This plugin allows you sign in with google using the Google SDK.

Platforms:

this plugin only works iOS and Android

Functions:

googleSignIn.init()

initialize google sign in

googleSignIn.signIn(clientID, hostedDomain, scopes, listener, serverClientID)

sign in to google

clientID(string) -- clientID for google sign (found in google console, see setup)

hostedDomain(string)(optional) -- The Google Apps domain to which users must belong to sign in.

scopes(array of strings)(optional) -- The API scopes requested by the app. example {"https://www.googleapis.com/auth/drive.appdata"} (see docs)

listener(function) if event.isError(boolean) is true, then event.error(string) will be returned. If event.isError is false, then event.email(string), event.userId(string), event.idToken(string), event.photoUrl(string), event.displayName(string), event.givenName(string), event.familyName(string), event.accessToken(string), event.serverAuthCode(string), and event.scopes(array of strings) will be returned

serverClientID(string) Web client (Auto-created for Google Sign-in)

googleSignIn.silentSignIn(clientID, hostedDomain, scopes, listener, serverClientID(optional) )

sign in to google without popup

clientID(string) -- clientID for google sign (found in google console, see setup)

hostedDomain(string)(optional) -- The Google Apps domain to which users must belong to sign in.

scopes(array of strings)(optional) -- The API scopes requested by the app. example {"https://www.googleapis.com/auth/drive.appdata"} (see docs)

listener(function) if event.isError(boolean) is true, then event.error(string) will be returned. If event.isError is false, then event.email(string), event.userId(string), event.idToken(string), event.photoUrl(string), event.displayName(string), event.givenName(string), event.familyName(string), event.accessToken(string), event.serverAuthCode(string), and event.scopes(array of strings) will be returned

serverClientID(string)(optional) Web client (Auto-created for Google Sign-in)

googleSignIn.signOut(listener)

sign out of google

listener(function) if event.isError(boolean) is true, then event.error(string) will be returned.

Setup:

Go to google console, create new project or open an existing project, go to credentials, create a new credential, select OAuth 2.0 client ID, make one for Web application and iOS, use Web application client id on android (see example below), on iOS click your created client id under OAuth 2.0 client IDs, you want to use this client id on iOS (see example below),and put "iOS URL scheme" into build.settings(see below). Also you need google service enabled in your build.settings (see below) and you need a google-services.json file( if you are using firebase you can skip this step). Go to this link, follow the steps, and put the file(google-services.json) in the root of your project.

Firebase setup:

go into authentication page on firebase and enable google sign in. Then you need to add you fingerprint under settings> general > your apps> select app> add fingerprint. Whats a fingerprint and how do I get it? Go here and get your fingerprint. Download google services files for iOS and Android. For android you have to include google services json file in the project. On iOS you don't have to for google sign in. On iOS you just need the "CLIENT_ID" from the google services plist for the client id .init() (also put into "iOS URL scheme" into build.settings(see below) ). On android the client id is in the google servies json under client>oauth_client>client_type = 3.

Build Settings:

Helpful Links:

Example

Support

Get Plugin