Skip to main content

Windows

This article guides you through setting up Google as an identity provider, enabling your Windows game to access Player Network authentication services.

Prerequisites

1. Set up the Google app on the Google Play Console
note

For IEGG projects, contact [miaruan (Ruan Mingjun)] for Google app registration and configuration.

1. Create a Google app

Register an account on Google Play Console following the prompts.

info

Google charges a fee of 25USD for the service. Please prepare a credit card in advance.

  1. Go to the Google Play Console.

  2. On the All apps page, click Create app to create a game app.

    Image: Google - create a game app

  3. Enter the app information.

    Image: Google - enter information for the app

2. Create a Play Games Services game project

Set up Play Games Services to manage game metadata and automate game production and distribution tasks.

  1. Go to Google Play Console.

  2. On the left navigation bar, select Grow > Play Games Services > Setup and management > Configuration.

  3. Under Does your game already use Google APIs, select the correct answer and your Play Games Services game project is created.

    Image: Google service creation

  4. In the Properties section, click Edit Properties.

  5. Enter basic game information and click Save changes.

    Image: Google basic game information

3. Add a credential to link the OAuth 2.0 client ID to your game
  1. Go to Google Cloud Platform.

  2. On the left navigation bar, click OAuth consent screen.

  3. Follow the instructions to setup the OAuth consent screen.

    Image: Google, consent to the agreement

  4. On the left navigation bar, click Credentials.

  5. On the Credentials page, select CREATE CREDENTIALS > OAuth Client ID to create an OAuth client ID.

    Image: Google, create OAuth clients

  6. In the Authentication type list, click Web.

  7. Enter the required information.
    In the Authorized redirect URLs 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 details page of the Web app.

    Image: Google, Web client details

  10. Find the Client ID and Client Secret, and enter them into the game configuration of the Player Network Console.

    Image: Google, Web client Client ID and Secret

  11. Add login test users.

    Image: Google, add test users

4. Configure for API access
  1. Go to Google Cloud Platform.

  2. On the left navigation bar, select Settings > Developer account > API access.

    Image: Google API console

  3. One the API access page, accept the Terms of Service.

  4. Click Link on the right of the corresponding project to link Google Play Console to the API project.

5. Add testers for your game
  1. Go to Google Play Console.

  2. On the left navigation bar, select Grow > 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

Before the game app is released, only testers can log in. Please make sure that the app is in the testing status.

6. Configure Achievements and Leaderboards

Find the Achievements and Leaderboards functions in the Games Services menu and configure them as needed.

Image: Google leaderboard

7. Get Google API ID

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

Image: Google ID

8. Get the Client ID and Client secret

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

Image: Google Web Client ID and Secret

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

Step 1: Configure the SDK for Google login

  1. Open the project's INTLConfig.ini:

    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 GAME_ID and SDK_KEY assigned by Player Network Console.
    • Set LOG_LEVEL = 1, LOG_CONSOLE_OUTPUT_ENABLE = 1, LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0, and LOG_COMPRESS_ENABLE = 0 to output console logs and log files without encrypting or compressing the output.
    • Set GOOGLE_WEBVIEW_LOGIN_ENABLE to 0 to use the system browser to log in to Google on Windows.
    • Replace {INTL_GOOGLE_CLIENT_REDIRECT_URL} with the webpage to redirect to after logging in with the system browser on Windows.

Step 2: Add Google login

info

Login with browser uses the loopback IP address to return data to the system. Since the data does not leave the system and does not have to pass through the Windows firewall, there is no need to configure the Windows firewall.

Windows games need to open the Google login webpage for players to log in through Google. Developers can open the Google login webpage in the following two ways:

  • To open the Google login webpage using Player Network SDK WebView, developers need to include "webview_login":true in the extraJson parameter when calling the Login method.
  • To open the Google login page using the system browser, developers need to include "webview_login":false in the extraJson parameter when calling the Login method.

Other than the above methods, developers can also define the default method to open Google login webpage by assigning a value to the GOOGLE_WEBVIEW_LOGIN_ENABLE field in the INTLConfig file.

Image: Google Login Web View

All Google operations require a connection to Google services.

Automatic Login (AuthLogin)

During automatic login, the device may be unable to connect to Google services. By default, Player Network SDK connects to Google services upon automatic login, which is recommended. (Game teams can disable the connection by configuring the GOOGLE_LOGOUT_NEED_CONNECT field as instructed in Google Channel Configuration.)

Login

Before calling Google login, Player Network SDK will check if Google Mobile Services (GMS) is available. The login service can be called only when GMS is available. If GMS is unavailable, Player Network SDK will return the error code returned by Google to games through the ThirdCode field of INTLAuthResult.

Return codeValueError Description
SERVICE_MISSING1The GMS is unavailable on the device.
SERVICE_VERSION_UPDATE_REQUIRED2The installed GMS version has expired.
SERVICE_DISABLED3The GMS is disabled.
SERVICE_INVALID9The installed GMS version is incorrect.
SERVICE_UPDATING18The GMS is being updated on the device.

For more information, see Google Docs and Google FAQs

  1. Add an observer to handle authentication 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 ret)
    {
    Debug.Log($"MethodID: {ret.MethodId}");

    string methodTag = "";
    if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
    {
    methodTag = "Login";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
    {
    methodTag = "Bind";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
    {
    methodTag = "AutoLogin";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
    {
    methodTag = "QueryUserInfo";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
    {
    methodTag = "GetAuthResult";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

INTLAPI.Login(INTLChannel.Google,"","\"webview_login\":true"); 
  1. Sync client authentication state with the game's backend and wait for the final authentication result.

Cancel Login

Windows games generally open a web browser for players to log in. If a player closes the login screen, the game is unable to receive a cancellation message. The game will only receive a timeout callback when the login attempt times out.

Therefore, it's recommended that when the Windows platform uses the system browser to log in, a cancellation button is added to the interface to facilitate the cancellation process. When the player clicks the button, the CancelLogin interface of Player Network SDK is called to cancel the login.

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

[Optional] Set up email permissions

Set up permissions to obtain the email address of players during Google login, returned as email in the ChannelInfo of AuthResult.

  • Email masking can be performed on the returned email according to compliance requirements, reach out to the Player Network representative to enable this feature.
  • The hashed base64(sha256(email)) can be reported to the backend logs, reach out to the Player Network representative to enable this feature.
  • Can be used to verify if email is present in a player's profile or third-party channel information, reach out to the Player Network representative to enable this feature.

Enable email return on Player Network Console by setting return_email to YES, see Configure Third-party Channels for detailed procedures.

Step 3: Test the login function

Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.

Step 4: Release your game

Before preparing for a production release, create a testing release with Android App Bundle.

The advantage of releasing a Beta version is that users can download it from Google play, but have no permission to add comments. A specific channel is set for users to submit feedback.

Create a production release
  1. Go to Google Play Console.

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

    Figure: Select corresponding channel

  3. Follow the instructions to create the production release.

    Image: Google beta testing

Change the publishing status
caution

If users do not release the app, authentication may fail.

  1. Go to the OAuth consent screen page of Google Cloud Platform.

  2. Change the Publishing status to PUBLISH APP.

    Image: Google app release