Skip to main content

Web

This article guides you through setting up Google as an identity provider, enabling your website 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 No. 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. Add Google as an authentication method for your project on Player Network Console.
note

For more details about integrating the SDK for other third-party channels, see JavaScript SDK.

Step 1: Install the JavaScript SDK

caution

Install the SDK package from the production environment when launching the game. The SDK package from the test environment is only used for integration testing.

Install the JavaScript SDK from npm or CDN.

$ npm install @intlsdk/account-api

Step 2: Instantiate the SDK

caution

Set env to the test environment during the integration testing and env to the corresponding production environment when launching the game.

const accountApi = new IntlgameAccountApi({
env: "test", // SDK environment
gameID: 11,
});
ParameterTypeDescriptionRemark
envstringSDK environment
For more information, see Retrieve cluster information.
Required
gameIDnumberUnique game ID assigned by Player NetworkRequired

Step 3: Implement web login

After instantiating the accountApi component, call the thirdAuthorize method to request the access token from Google.

accountApi.thirdAuthorize({
third_type: 'google',
}).then(
(res) => {
console.log(res);
});

With the Google token returned, call the intlAuthorize method to get the Player Network SDK OpenID and token to log in to your website.

accountApi.intlAuthorize({
third_type: 'google',
channel_info: {
code: "EAAI2lTrXAZBwBAC"
}
}).then(
(res) => {
console.log(res);
});

Call the intlLogout method to log out from your website.

accountApi.intlLogout({
token: '4567xsdfsd',
openid: 'xxxxxxxx',
channel_id: 6,
}).then(
(res) => {
console.log(res);
});