Google Play Games Sign In - old

This setup is for a absolut basic setup, using the Google Play Games Login only. Assuming you build your app from scratch.

💖 Health Check / Goal Project

  • Windows 10 Home, 21H1, OS Build 19043.1165

  • Unity 2021.2.9f1 (February 02, 2022)

    • Module: Android Build Support

    • Module: iOS Build Support (only to avoid a bug using the GPGS Plugin)

  • Play Games Plugin for Unity 0.12.10

  • 2D Mobile App

  • Minimum SDK: API Level 22

Set up a new Unity Project

  • Select any template of your choice.

  • Project Name: MyApp

  • Location: Anywhere

Set up Android

File > Build Settings > Android

  • Switch Platform

  • Check Build App Bundle (Google Play)

  • Click Switch Platform

Edit > Project Settings > Player

  • Other Settings

    • Identification

      • Check Override Default Package Name

      • Override Default Package Name > Set your <com.mycomp.myapp>

      • Version -> 0.1.0

        • It doesn't matter what version you are inserting here

      • Bundle Version Code-> 1

        • Has to be increased manually every time before you upload it the chnged app once again to Google Play.

      • Minimum API Level -> Select any Android version of your choice

      • Target API Level > Automatic (highest installed)

    • Configuration

      • Scripting Backend -> Select IL2CPP

      • Target Architectures -> Check ARM64

  • Publishing Settings

    • Keystore Manager

      • Dropdown Keystore > Create New > Dedicated Location

        • > save as myapp.keystore

        • Fill out all fields as you like

Note that this keystore will generate one specific upload key which can be used to debug locally. Using this keystore, Google will automaticallly create an app sign key after you uploaded it to Google Play for the first time. This app sign key is the one which has to be registered with the credentials.

Unity -> File -> Build Settings -> Build

Google Play Console App: Set up app

Create the App online

  • Go to Google Play Console > Create App >

    • Enter your appname: MyApp

    • Default Language: Select Englisch (United States) - en-US

    • App or Game: Select Game

    • Free or Paid: Select Free

    • Declarations:

      • Check Developer Policies

      • Check US Export Laws

  • Click Create App

Set up App Basics

  • Dashboard > Set up your app > COVID-19 contact tracing and status apps

    • Select My app is not a publicly available COVID-19 contact tracing or status app

    • Click Save

Upload your .aab

  • Setup -> App Integrity

  • App bundles -> Upload MyApp.aab

  • Click Save

From here on an App signing key is automatically created and stored by Google.

Configure Credentials

  • Play Games Services > Setup and Management > Configuration

    • Select No, my game doesn't use Google APIs

    • Game Name MyApp

    • Credentials > Configure OAuth Consent Screen

Go to Google Cloud Console

  • User Type -> External

  • Click Create

  • OAuth Consent Screen

    • App Inforamtion

      • App Name: MyApp

      • User Support Mail: Enteryoursupportmail@yourcompany.com

    • Developer contact information

      • Enter yourtechmail@yourcompany.com

    • Click Save and Continue

  • Scopes

    • Click Save and Continue

  • Close this tab

Create OAuth

  • Click Add Credential

  • Click Create OAuth Client

  • Enter all values as given

    • Application Type: Android

    • Name: MyApp

    • com.mycomp.myapp

    • SHA1

      • The app signing key certificate generated by google.

        • Find it in Google Play Console -> Setup -> App Integrity

  • Download the oauth.json and close the tab

  • Select the newly created OAuth client

  • Go back to Google Play Console -> Select newly created OAuth Client

  • Click Save changes

This credential is used for the official login and only works after you uploaded it to the google play store. If you want to login locally, you have to use the SHA1 of your upload key.

Repeat the steps on Create OAuth . The only difference is to insert the upload key instead of the app signing key. You can retrieve the key by executing:

Add this key to the credentials allows you to sign in on your local device. Requirement is the to be built fully.

Add a Tester

Play Games Services -> Setup and Management -> Testers -> Tab Testers > Add the email you will login on your mobile device. It has to be a Gmail-account.

Google Play Services Plugin: Setup

  • Install the GPGS Plugin for Unity.

    • Install the latest Play Games Plugin For Unity in your Unity project.

      • Download GooglePlayGamesPlugin-0.10.12.unitypackage file

      • Double click it while unity is open to install it.

  • Apply Google Play Services Resource

    • Go to Google Play Console > Your App > Play Games Services > Configuration > Credentials > Get resources (on the right hand side)

      • Copy its content

    • Unity > Window > Google Play Games > Setup > Android Setup ...

      • insert copied resource content

      • Click Setup

The resource file should look similar to the following:

As long as you don't use any services such as achievements or leaderboard, no constant file will be created.

Implement the code

Add new C# script in project window. Drag and drop this script to any object in the Hierarchy view. To keep it easy, drag it onto the Main Camera

If you can't add it, you propably renamed your script, but didn't change the class name within the script itself.

Add a simple text button to show login result: Right click Hierarchy > UI > TextMeshProUGUI.

If it is the first time you are using a TextMeshProUGUI component, you will be notified to import the TMP Essentials. Examples and Extras are not needed.

Select Main Camera in the Hierarchy window and drag the newly created Text object in Hierarchy onto the this GameManager script > Login Result : Field None (Text Mesh Pro UGUI)

Publish your app including Google Play Games Login

  1. In Unity > Edit > Project Settings > Other Settings > Identification > Increase Build Version Code by one.

  2. In Unity > File > Build Settings > Click Build

  3. Upload your .aab to Google Play as you did in Upload your .aab

  4. Save > Review Release > Start Rollout to Interal Testing

  5. Internal Testing > Tab Testers > How to join your test > Follow the link

Last updated

Was this helpful?