Google SignIn

The Google Sign-In plugin is specifically designed to implement Google authentication or login features and Google profile in the Google Android SDK and Google iOS SDK in your applications on Android and iOS, for games built in Construct 3 and Construct 2.


The Google Sign-In plugin include features such as Google Authentication, Silent Google Authentication, Google Profile information including the display name, email address, family name, given name, image url link and user id.


The Google Sign-In plugin also supports requesting server credentials for back-end implementations or server services, such as PlayFab. The Google Sign-In plugin can provide an id token and server authentication code.

PlayFab API v2.png

Introduction

Step 1.png

The Construct Master Collection supports the full and easy integration of native mobile Android SDKs and iOS SDKs for both Construct 3 and Construct 2.


Please click here to learn more about Mobile.

Features


The Google Sign-In plugin is specifically designed to implement Google authentication or login features and Google profile in the Google Android SDK and Google iOS SDK in your applications on Android and iOS, for games built in Construct 3 and Construct 2.


The Google Sign-In plugin include features such as Google Authentication, Silent Google Authentication, Google Profile information including the display name, email address, family name, given name, image url link and user id.


The Google Sign-In plugin also supports requesting server credentials for back-end implementations or server services, such as PlayFab. The Google Sign-In plugin can provide an id token and server authentication code.


Here are some of the native features of the mobile plugin:

  • Google Authentication

  • Google SignIn

  • Google Profile

  • Google Server

  • Display Name

  • Email Address

  • Family Name

  • Given Name

  • Google Image URL

  • Google User Id

  • Server authentication code or ServerAuthCode()

  • Server Id token

  • PlayFab integration

For more information about native mobile or Android and iOS features, please click here to learn the introductory lessons to Mobile.


Platform Integration


Here are some of the platforms that are natively supported:

  • Android

  • iOS

  • Native Android

  • Native iOS


Build Support


Here are some of the supported build options:


Editor Features


Here are some of the features in the Construct editor:

  • Construct 3

  • Construct 2

 
 

How to use?

It is easy to use the Google SignIn plugin, you will only need to follow the steps below.

1. The first step is to add the Google SignIn object into the project.


2. To enable logs in the console for mobile debugging, enable the Debug Mode property in the Properties bar. This is useful for mobile usb debugging using Chrome inspect devices on Android or Safari web inspector on iOS.



3. To be able to get the server credentials like the id token or the server auth code, the Web Client Id must be filled, which is useful for server-side integrations including services like PlayFab.

  • You can generate a web client id at your project's API credentials page in the Google Developer Console.

  • If you plan to run this on a browser, ensure to also add your URL address (for example: http://localhost:3000) in the Authorized JavaScript origins section.



4. The Reversed Client ID is a field that varies depending on the platform.

  • Android - Input the reverse value of the Client ID on your Google application's Android generated configuration file. From the Google Developer Console, this would be : com.googleusercontent.apps.uniqueId Example: 123-abc123.apps.googleusercontent.com would become com.googleusercontent.apps.123-abc123.​

  • iOS - The value can be found on your Google application's iOS generated configuration file. Click to generate the configuration file.

  • In iOS, this field is the "iOS URL Scheme" in the developer console and Xcode.

 
 

Documentation

Here are the following official documentation and guides into setting up your Google Sign-In integration.


Google Console Setup


There are some few steps required by Google to properly integrate the Google Sign-In Android SDK and Google Sign-In iOS SDK.


Android


  1. To configure Android, you need to generate a configuration file, one way is through Firebase. The file will be named google-services.json.

  2. Enable Google Sign-In and create an Android application to register the SHA-1 fingerprint of the debug or release application.

  3. To get the SHA-1 fingerprint, proceed to the Android Build Registration documentation section below.

  4. Once Google Sign-In is enabled, credentials will be automatically generated in the Google Developers Console for web and android, from the Google Cloud Platform. There is no need to import the generated google-services.json file into your Construct 3 project for this plugin since the necessary credentials are already inputted into the project. Please do note that other plugins may still require the google-services.json file in your Construct 3 project, for example the Mobile Firebase Analytics plugin.

  5. Please configure the consent dialog screen in Google Cloud, which is required by Google for sign-in privacy compliance.


iOS

  • To configure iOS, you need to generate a configuration file, one way is through Firebase. The file will be named GoogleService-Info.plist, which will contain the reversed client id which you need to fill in the Google Sign-In plugin's properties.

  • In iOS, this field is the "iOS URL Scheme" in the developer console and Xcode.



Android Build Registration


Android builds have more setup requirements mandated by Google, this is to allow only certain builds to integrate the Google Sign-In SDK.


Google Credentials Registration


  • To allow and properly integrate Google Sign-In for your application builds, you need to register the SHA-1 fingerprint of your application build into Google Credentials Manager.

  • In Google Credentials Manager, create a credential for OAuth2 client and input the SHA-1 fingerprint of either your debug or release application.

  • It is best to create an OAuth2 client for both your debug SHA-1 fingerprint certificate and release SHA-1 fingerprint certificate. You can do this to easily test Google Sign-In on both your debug and release applications.

  • You can get your SHA-1 fingerprint of your application build in various ways:

  • Command Line with keytool

  • Android Studio

  • Construct 3 Build Service's release .apk's SHA-1 fingerprint

  • For more information in how to set these, please proceed to the next documentation section, Getting the SHA-1 fingerprint.


Getting the SHA-1 fingerprint


  • There are various ways to get the SHA-1 fingerprint of your application, as mentioned in the last section. For your reference, here are the links below:

  • Command Line with keytool

  • Android Studio

  • Construct 3 Build Service's release .apk's SHA-1 fingerprint

  • To make this process easier, here are some guides and tips into getting the SHA-1 fingerprint of your application build.

  • Quick way - the easiest, quickest and most convenient way to get the SHA-1 fingerprint without any technicalities is through the Construct 3 Build Service.

  • However, you can only do this when exporting a release application (.apk or .aab).

  • The Construct 3 Build Service doesn't provide the SHA-1 fingerprint for debug application (.apk) exports. This means that you cannot use the mobile debugging tools while testing the Google Sign-In plugin.

  • Fortunately, in most cases, you might not even need the mobile debugging tools, we constantly maintain the plugin and have active bug report tracking and support channels that in most circumstances there should be nothing to debug.

  • Although, if you must use the mobile debugging tools, you would most likely be able to easily do the other methods in getting the SHA-1 fingerprint of your application build, both for debug and release applications (.apk or .aab).

  • Advanced way - the official way to generate the SHA-1 fingerprint for your debug and release application builds is to use the command line utility application named keytool.

  • Syntax: $ keytool -exportcert -keystore <path-to-debug-or-production-keystore> -list -v -alias <alias-name>

  • Please click the link to visit a guide on how to use the keytool utility.

  • Please click the link to visit the official documentation.

  • Android Studio - If you prefer building through the Cordova CLI or Android Studio, you can also easily get the SHA-1 fingerprint of your application build for both debug and release exports (.apk or .aab).

  • Additional guide for getting the SHA-1 fingerprint of your application builds, for both debug and release exports on Android Studio.


Google Credentials Registration


  • Once you have your build credentials, the SHA-1 fingerprint of your application build, either debug or release builds, you then need to register it to the Credentials page in your Google API Console.

  • Please follow the steps below to proceed:

  1. Click Create credentials > OAuth client ID.

  2. Select Android.

  3. In the Package name field, enter your Android application's package name.

  4. Paste the SHA-1 fingerprint into the form's field where requested.

  5. Finally, click Create, and then you're done.



Additional Information


Additional information regarding integrating the Google Sign-In Android SDK and Google Sign-In iOS SDK into an application create in Construct 3 and Construct 2.


Publishing your app in Google Play


  • Google signs your application with a different certificate when you publish it in the Google Play Store. Once your application is published, copy the SHA-1 fingerprint of the App signing certificate found in the App signing section under Release Management, in Google Play Console.

  • Paste the copied SHA-1 fingerprint in the Release OAuth client ID in the Google Credentials Manager.



Troubleshooting


Follow the troubleshooting guide below if ever you encounter any issues.

  • I cannot get sign-in to work on Android. And, why is there no Android API key?

  • On Android you need to register your application build's SHA-1 fingerprint, please see the Google Credentials Registration documentation section.

  • Why is this not working on my Android Emulator?

  • Please make sure you are using a virtual device running with Google API and/or Google API's CPU.

  • We highly recommend using Android Studio's official Android Virtual Device (AVD) for device emulation purposes.

  • I am getting an Error 10 in the mobile debugging console.

  • Release application builds

  • This is most probably caused by your application build not using the release keystore you want to use or should use.

  • I am getting an Error 16 in the mobile debugging console.

  • Release application builds

  • Please make sure you have registered the right SHA-1 fingerprint. Specifically, the SHA-1 fingerprint of the application build with the matching release keystore.

  • Debug application builds

  • Please note that the Construct 3 Build Service does not provide an SHA-1 fingerprint for debug .apk builds. However, using keytool or Android Studio methods of getting the SHA-1 fingerprint will do.

  • Register the correct SHA-1 fingerprint of your debug application.

  • For more information, please visit the Android Build Registration guide in the documentation section.

 

Actions, Conditions & Expressions

Actions

press to zoom

press to zoom
1/1

The following action groups:

  • Authentication

Authentication

  • Login - Login to Google.

  • Silent Login - Silently Login to Google. But check if already signed in to the app and sign in silently if true.

  • Logout - Logout from Google. This will clear the OAuth2 token.

  • Disconnect - Disconnect from Google. This will clear the OAuth2 token, forget which account was used to login, and disconnect that account from the app.

Conditions

The following condition groups:

  • Login

  • Silent Login

  • Logout

  • Disconnect

  • General

press to zoom

press to zoom

press to zoom
1/2

Login

  • On Login - Triggered when the "Login" has succeeded.

  • On Login Failed - Triggered when the "Login" has failed.



Silent Login

  • On Silent Login - Triggered when the "Silent Login" has succeeded.

  • On Silent Login Failed - Triggered when the "Silent Login" has failed.


Logout

  • On Logout - Triggered when the "Logout" has finished.


Disconnect

  • On Disconnect - Triggered when the "Disconnect" has finished.


General

  • Is Logged In - Checks if the "Google Login" has been established.

Expressions

press to zoom

press to zoom
1/1

The following expression groups:

  • Authentication

  • General

Authentication

  • getEmail - Return the "Email Address" from the login.

  • getUserID - Return the "User ID" from the login.

  • getDisplayName - Return the "Display Name" from the login.

  • getFamilyName - Return the "Family Name" from the login.


  • getGivenName - Return the "Given Name" from the login.

  • getImageURL - Return the "Image URL" from the login.

  • getIDToken - Return the "ID Token" from the login. This requires the "Web Application Client ID" input on the Properties Bar.

  • getServerAuthCode - Return the "ServerAuthCode" from the login. This requires the "Web Application Client ID" input on the Properties Bar.

  • getAccessToken - Return the OAuth2 "Access Token" from the login.

  • errorMessage - Return the "Error Message" from a failed login attempt.



General

  • eventResponse - Return the event response data in JSON string for a recently fired event trigger.

Object   Properties

Plugin Properties

press to zoom

press to zoom
1/1

The following property groups:

  • Configuration

  • Browser

  • Mobile

Configuration - The options to set the plugin settings.

  • Debug - If checked, the runtime will log runtime notifications. This should be unchecked on production builds.


Browser - Web Browser credentials.

  • Web App Client ID - The Browser platform requires a valid WEB_APPLICATION_CLIENT_ID that is generated in the Google Developer Console.


Mobile - Google Sign-In credentials.

  • Reversed Client ID - On iOS, it requires a valid REVERSED_CLIENT_ID that is contained in the GoogleService-Info.plist. On Android, input the reverse value of the Client ID found in your Google application's Android generated configuration file.

 
 

Showcase

The Google SignIn is a plugin that integrates the native mobile Google SignIn Android SDK and Google SignIn iOS SDK into an application made in Construct 3 or Construct 2. It allows you to implement Google authentication and Google profile into your game application projects.



 

Game Projects 

Instructions Kit

Construct 3 Project
Construct 3 Project

press to zoom
Construct 2 Project
Construct 2 Project

press to zoom
Construct 3 Project
Construct 3 Project

press to zoom
1/2

Specifications

  • Instructions - The game project contains instructions and steps on how to use the addon and its features.

  • Action, Conditions and Expressions - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks on the recommended ways of using the addon.

Supporters

Only