Google Sign In Plugin

Get users into your apps quickly and securely, using a registration system they already use and trust with Google Sign In

Platforms:

this plugin only works iOS and Android

Functions:

googleSignIn.init(options)

initialize google sign in

options(table) -- {

ios={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.", serverClientID(string)(optional) Web client (Auto-created for Google Sign-in)},

android={clientId(string)= "clientID for google sign (found in google console, see setup)", scopes(array of strings)(optional) The API scopes requested by the app. example {"https://www.googleapis.com/auth/drive.appdata"} (see docs)", hostedDomain(string)(optional) = "The Google Apps domain to which users must belong to sign in.", serverClientID(string)(optional) Web client (Auto-created for Google Sign-in)}

}

googleSignIn.signIn(listener)

sign in to google

listener(function) event.status== "signed in", "cancelled", "error". 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), event.scopes(array of strings) will be returned

googleSignIn.silentSignIn(listener)

sign in to google without popup

listener(function) event.status== "signed in", "cancelled", "error". 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

googleSignIn.signOut(listener)

sign out of google

listener(function) event.status== "signed out", "error". if event.isError(boolean) is true, then event.error(string) will be returned.

googleSignIn.disconnect(listener)

disconnect current google user from app

listener(function) event.status== "signed out", "error", "disconnected". if event.isError(boolean) is true, then event.error(string) will be returned.

googleSignIn.getCurrentUser(listener)

returns the current user infomation if signed in

listener(function) event.status== "account data found", "not signed in". if event.isError(boolean) is true, then event.error(string) will be returned and 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), event.scopes(array of strings)

googleSignIn.requestScope(scope, listener)

requests scopes for a signed in user

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

listener(function) event.status== "scope request successful", "scope request canceled", "request scope failed", "error". if event.isError(boolean) is true, then event.error(string) will be returned and 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), event.scopes(array of strings)

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 Android/iOS, on Applcation type "Android" make sure to add SHA-1(learn more here) and Package Name (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:

Get Plugin

Example

Support