Skip to main content

Windows

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

Prerequisites

1. Set up the Facebook app on Meta for Developers
1. Register for an account

Before you can configure your app for the required platforms, you need to register a Facebook developer account and create an app in the Facebook App Dashboard.

  1. Go to the Facebook website. Register for an account and finish the account authentication (by email or phone) according to the prompts.

  2. Activate a developer account in Meta for Developers.

    Image: Activate a Facebook developer account

  3. Consent to the agreement and continue.

    Image: Consent to the agreement and continue

  4. Complete mobile phone verification.

    Image: Mobile phone verification

  5. Complete email verification.

    Image: Mobile phone verification

  6. Complete the registration.

    Image: Complete registration

  7. Add Facebook SDK to the project in Meta for Developers.

2. Create an app
  1. Click Create App in the upper right corner.

    Image: Create an app

  2. Select Authenticate and request data from users with Facebook Login as the app type.

    Image: Gaming app

  3. Select Business if available, else proceed to the next step.

    Image: Gaming app

  4. Enter the basic information.
    The FACEBOOK_DISPLAYNAME in the INTLConfig.ini configuration file should be the App name here.

    Images: Enter basic information

  5. Agree and continue.

    Images: Enter basic information

3. Configure the app
caution

Follow Facebook specifications to enter the Privacy Policy URL, User Data Deletion, and Terms of Service URL. If you do not follow Facebook specifications, Facebook may disable your app after it is released.

note

For apps that have been already submitted to Facebook, they can continue to use Facebook Login For Gaming. New apps that have not been submitted are only allowed to use Facebook Login, see Facebook Login For Gaming for more information.

  1. In the left sidebar, click App Settings > Basic to view basic information about the application, such as App ID and App Secret.

    Images:Add app platform

  2. In the Privacy Policy URL field, enter the web address of the Privacy Policy.

  3. In the User Data Deletion field, select the data deletion instructions URL, and enter the web addresses according to the user's instructions for data deletion.

  4. In the Terms of Service field, Enter the URL of the Terms of Service webpage.

  5. Click Add Platform and select Windows to add an Windows app.

  6. Enter the configuration directly, or click Quick Start in the top right corner of the platform configuration interface and set the configuration based on the guide.

    Image: Add platform configuration

  7. Click Save Changes to save the configuration.

Configure Facebook Login
  1. In the Facebook App Dashboard, click Use cases > Customize.
    Image: Facebook Login Windows
  2. Select Settings under Facebook Login.
  3. In Valid OAuth Redirect URIs, enter https://common-web.intlgame.com/jssdk/facebooklogincallback.html and https://test-common-web.intlgame.com/jssdk/facebooklogincallback.html.
  4. In Allowed Domains for the JavaScript SDK, enter https://common-web.intlgame.com/ and https://test-common-web.intlgame.com/.
  5. Turn on Embedded Browser OAuth Login.
    Image: Facebook Login Windows
  6. Click Save changes at the bottom of the page to save the configurations.
4. Add the testing permissions

Before the app is released, only test users or users who are added into the permission list have access to Facebook functions.

  1. In Facebook App Dashboard, click Roles.
  2. Click Add Administrators/Add Developers/Add Testers to add respective roles.

Image: Add test users

5. Verify your business

Certain Meta technologies or features require you to go through the Meta business verification. For more information, reach out to the Player Network representative.

Image: Add Test User

  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 Facebook as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK for Facebook login

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
[Facebook]
FACEBOOK_WEBVIEW_LOGIN_ENABLE = 0
FACEBOOK_CLIENT_REDIRECT_URL = {INTL_FACEBOOK_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 the value of FACEBOOK_WEBVIEW_LOGIN_ENABLE. The default value is 0, indicating that the Windows platform uses the system browser for login. If users set the value to 1, the Windows platform uses WebView for login.
  • Replace {INTL_FACEBOOK_CLIENT_REDIRECT_URL} with the webpage that is redirected to after login.
caution

If FACEBOOK_WEBVIEW_LOGIN_ENABLE in INTLConfig is set to 1, integration of the INTLWebView plugin is required, otherwise the login will not be successful.

Step 2: Add Facebook 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 Facebook login webpage for players to log in through Facebook. Developers can open the Facebook login webpage in the following two ways:

  • To open the Facebook 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 Facebook 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 Facebook login webpage by assigning a value to the FACEBOOK_WEBVIEW_LOGIN_ENABLE field in the INTLConfig file.

Player Network authentication services also supports Facebook Login for Gaming. For more information, see the Technical Implementation section of the Facebook official documentation.

  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.

    • Facebook Login

      // taking Facebook as example
      INTLAPI.Login(INTLChannel.Facebook);
    • Facebook Login for Gaming

      Call the Login method with the permission parameter to retrieve Facebook profile picture. For more information, see Requesting User's Profile Picture.

      //Add a `gaming_user_picture` permission to the original permissions string, like this: `"email,public_profile,gaming_user_picture"`
      public static void Login(string channel, string permissions = "gaming_profile,gaming_user_picture", string extraJson = "{}");
  4. 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 through Facebook. 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 to Facebook, 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.CancelLogin(INTLChannel.Facebook);

[Optional] Set up email permissions

Set up permissions to obtain the email address of players during Facebook 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.
  1. Configure the email permission on Meta for Developers. The email permission requires Advanced access, in order for all apps to be able to obtain player email.

    Image: Facebook permission request

  2. Add email to the permissions parameter when calling the Login API. If the permissions parameter is not specified or is empty when calling the Login API, the email permission will be added.

  3. 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.