Skip to main content

Windows

The purpose of this article is to explain how to set up Google Authentication so that your game can be logged in through the Google channel using the Player Network login authentication service.

Prerequisites​

1. Set up your game in the Google Play admin center
note

For the IEGG project, please contact [miaruan (Ruan Mingjun)] for Google Apps registration and configuration.

1. Create Google Apps

Follow the prompts to register an account on Google Play Console.

info

Google charges a $25 service fee.Please have your credit card ready in advance.

  1. Go to Google Play Console.
  2. On the All apps page, click Create app to create the game app.

    Image: Google - create a game app
  3. Enter the application information.

    Image: Google - enter information for the app
2. Configuring the Play game service

Set up the Play game service to manage game metadata and automate game production and distribution tasks.

  1. Go to Google Play Console.
  2. In the left navigation bar, select Grow users > Play Games Services > Setup and management > Configuration.
  3. Under Which Play Games Services project do you want to use, select the corresponding option to create a Play Games Services project.

    Image: Google service creation
  4. In the Properties section, click Edit Properties.
  5. Enter the basic information about the game and click Save changes.

    Image: Google basic game information
3. Add a credential to connect the OAuth 2.0 client ID to the game
  1. Go to Google Cloud Platform.
  2. In the left navigation bar, click OAuth consent screen.
  3. Follow the instructions to set up the OAuth OAuth consent screen.

    Image: Google, consent to the agreement
  4. Click Clients on the left navigation bar.
  5. On the Clients page, select CREATE CLIENT > Create OAuth Client ID to create an OAuth client ID.

    Image: Google, create OAuth clientsI
  6. In the Application type list, click Web application.
  7. Enter the required information.

    In the Authorization Redirection section of the Web Application details page, add https://test-common-web.intlgame.com/jssdk/googlelogincallback.html and https://common-web.intlgame .com/jssdk/googlelogincallback.html.

    Image: Windows redirect URIs
  8. Click SAVE to complete the configuration.
  9. Go to the Web application details page.

    Image: Google, Web client details
  10. Locate the Client ID and Client Secret and enter them into the Player Network console's game configuration.

    Image: Google, Web client Client ID and Secret
  11. Click Audience > ADD USERS to add a login test user.

    Image: Google, add test users
4. Adding tester privileges
  1. Go to Google Play Console.
  2. In the left navigation bar, select Grow users > Play Games Services > Setup and management > Testers.
  3. In the Testers tab, click Add testers to add testers for your game.

    Image: Google testers
note

Only testers can log in until the game app is released.Make sure that the application is in a test state.

5. Configure achievements and leaderboards

Locate the Achievements and Leaderboards features on the Gaming Services screen and configure them as needed.

Image: Google leaderboard

6. Obtain Google API ID

Access the Information Center from the Google Cloud Platform panel.The Google API ID is the Project No. on this page.

Image: Google ID

7. Obtain Client ID and Client secret

Follow the steps in 3. Add a credential to link the OAuth 2.0 client ID to the game to obtain the application information.

Image: Google Web Client ID and Secret

  1. Add Google as a business login authentication method in the Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download SDK.
  4. Integrate SDK.
  5. Add Google as a business login authentication method in the Player Network Console.

Step 1:Configure SDK for Google Sign-in​

  1. Open your project's INTLConfig.ini file:
INTLConfig.ini
[INTL environment]
# WARNING: You should change this URL to the production environment when you release your game.
INTL_URL = https://test.intlgame.com
GAME_ID = {INTL_GAME_ID}
SDK_KEY = {INTL_SDK_KEY}
[INTL Log]
LOG_LEVEL = 1
LOG_CONSOLE_OUTPUT_ENABLE = 1
LOG_FILE_OUTPUT_ENABLE = 1
LOG_ENCRYPT_ENABLE = 0
LOG_COMPRESS_ENABLE = 0
[Google Channel Configuration]
GOOGLE_WEBVIEW_LOGIN_ENABLE = 0
GOOGLE_CLIENT_REDIRECT_URL = {INTL_GOOGLE_CLIENT_REDIRECT_URL}
  • Set the SDK backend environment to INTL_URL = https://test.intlgame.com .
  • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the values assigned by the Player Network Console: GAME_ID and SDK_KEY .
  • Set ``,LOG_LEVEL = 1 , ``,LOG_CONSOLE_OUTPUT_ENABLE = 1 , and `` LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0 and LOG_COMPRESS_ENABLE = 0 , so that console logs and log files are output without encryption or compression.
  • Set GOOGLE_WEBVIEW_LOGIN_ENABLE to 0 to use the system browser to sign in to Google on Windows.
  • Replace {INTL_GOOGLE_CLIENT_REDIRECT_URL} with **Web Client ID **. This is the client ID for the web application in the " **" section of the OAuth API configuration **, also known as the Server Client ID in the OAuth 2.5 API configuration.

Step 2:Add Google Login​

info

Using a browser login returns data to the system using the loopback IP address.There is no need to configure Windows Firewall because the data does not leave the system and does not need to pass through Windows Firewall.

Games on the Windows platform that require the player to sign in via Google will need to open the Google Sign In page.Developers can open the web client for login in two ways:

  • To open the Google login page using the Player Network SDK's built-in WebView, set extraJson to "webview_login":true when calling the login API.
  • To open the Google login page using the system browser, set extraJson to "webview_login":false when calling the login API.

In addition, developers can configure the default way to open Google login pages by using the GOOGLE_WEBVIEW_LOGIN_ENABLE value in the INTLConfig configuration file.

Image: Google Login Web View

All Google actions require a connection to Google services.

AuthLogin​

During automatic sign-in, the device may not be able to connect to Google services.It is therefore recommended to let Player Network SDK connect to Google services during automatic login by default.(Game teams can disable this connection by configuring the GOOGLE_LOGOUT_NEED_CONNECT field in the Google Channel Configuration section of the INTLConfig configuration file.).

Log on to​

Before calling Google Login, the Player Network SDK checks to see if Google Mobile Services (GMS) is available.The login service can only be invoked when GMS is available.If GMS is not available, the Player Network SDK will return the error code sent by Google to the game via the ThirdCode field of INTLAuthResult.

Return CodeReturn valuemisdescription
SERVICE_MISSINGstringGMS is not available on the device.
SERVICE_VERSION_UPDATE_REQUIRED2The installed version of GMS is out of date.
SERVICE_DISABLED3GMS is disabled.
SERVICE_INVALID9The version of GMS installed is incorrect.
SERVICE_UPDATING18The GMS on the device is being updated.

For more information, see Google Docs and Google Frequently Asked Questions

  1. Register login-related callbacks.
// Add callbacks
public void AddAuthObserver()
{
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
}

// Remove callbacks
public void RemoveAuthObserver()
{
INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
}

// Process the INTLAuthResult callback
public void OnAuthResultEvent(INTLAuthResult AuthResult)
{
Debug.Log($"MethodID: {AuthResult.MethodId}");

string methodTag = "";
switch (AuthResult.MethodId)
{
case (int)INTLMethodID.INTL_AUTH_LOGIN:
methodTag = "Login";
break;
case (int)INTLMethodID.INTL_AUTH_BIND:
methodTag = "Bind";
break;
case (int)INTLMethodID.INTL_AUTH_AUTOLOGIN:
methodTag = "AutoLogin";
break;
case (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO:
methodTag = "QueryUserInfo";
break;
case (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT:
methodTag = "GetAuthResult";
break;
}
}
  1. Call the AutoLogin interface for automatic login.
INTLAPI.AutoLogin();
  1. If automatic login fails, call the Login method to let players log in manually.
INTLAPI.Login(INTLChannel.Google,"","\"webview_login\":true"); //Open the Google login page using the WebView component of the Player Network SDK
  1. Synchronize client authentication status with the game backend, waiting for final validation results.

Cancel Login​

On the Windows platform, when logging into a three-way channel using the system browser, if the user closes the login screen, the game will not receive the cancel login message in a timely manner.The game triggers the timeout callback only when the login times out.

To solve the above problem, it is recommended that a cancel login button be added to the login screen when logging in using the system browser.Users can actively cancel the login operation by clicking this button.In this case, the game needs to call the CancelLogin interface of the Player Network SDK to ensure that it can respond in a timely manner if the user actively cancels the login.

INTLAPI.Login(INTLChannel.Google, "", "{\"cancel_login\":1}");
//Available after Player Network SDK 1.17
INTLAPI.CancelLogin(INTLChannel.Google);

[Optional] Set email permission​

To get the player's email when logging in to Google, you need to set the corresponding permission, which will return email in the ChannelInfo of AuthResult.

  • For compliance reasons, the returned email can be masked for specific sources. If needed, please contact the Player Network assistant to enable it.
  • In the background log, you can report the hash of base64(sha256(email)). Contact Player Network Assistant if needed.
  • Can be used to verify whether the player's information or the binding list contains email information. Contact Player Network Assistant if needed.

Enable the email return feature in the Player Network Console by setting return_email to YES. For details, see Third-Party Channel Configuration.

Step 3: Acceptance testing for login functionality​

Search for the keyword "AuthResult" in the Player Network SDK logs to confirm whether the channel name and OpenID are returned correctly.If correct, it means the integration configuration is successful, and login functionality has been successfully added.

If you encounter problems during the integration process, please refer to Frequently Asked Questions.

Step 4:Publish the game​

Before you are ready to release a production version, create a test version using Android App Bundle.

The nice thing about releasing Beta is that users can download it from Google play, but don't have access to add comments.Specific channels are set up for users to submit feedback.

Creating a production version
  1. Go to Google Play Console.

  2. In the left navigation bar, select Release > Production.

    Figure: Select the corresponding channel

  3. Follow the instructions to create a production version.

Image: Google beta testing

Changing the Publishing Status
caution

Authentication may fail if the user does not release the application.

  1. Go to the OAuth consent screen page of Google Cloud Platform.
  2. Change PUBLISHING STATUS to PUBLISH APP.

Image: Google app release