Skip to main content

Android

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

Prerequisites

1. Set up the DMM app

Contact DMM tech support to obtain a developer account with relevant permissions and app parameters.

Required app parameters:

  • App ID
  • Secret key
  • Consumer key
  • Consumer secret
  • Authentication client ID
  • Authentication client 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 DMM as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK

caution

Because the DMM SDK is only compatible with minSdkVersion >=23 or later, it may have problems when running on Android 6.0 or earlier. Set minSdkVersion >= 23 for games.

  1. Open the project's INTLConfig.ini:

    [Android LifeCycle]
    LIFECYCLE=DMM
    [DMM]
    DMM_DEVELOP_MODE = {INTL_DMM_DEVELOP_MODE}
    DMM_APP_ID = {INTL_DMM_APP_ID}
    DMM_CONSUMER_KEY = {INTL_DMM_CONSUMER_KEY}
    DMM_CONSUMER_SECRET = {INTL_DMM_CONSUMER_SECRET}
    DMM_AUTHENTICATION_CLIENT_ID = NONE
    DMM_AUTHENTICATION_CLIENT_SECRET = NONE
    DMM_GET_VALIDATE_CODE_PATH = /v2/auth/get_dmm_verify_code
    DMM_REDIRECT_URL = {INTL_DMM_REDIRECT_URL}
    DMM_SECRET_KEY = NONE
  • Add DMM to LIFECYCLE. For more information, see SDK Environment.
  • Replace {INTL_DMM_DEVELOP_MODE} with sandbox and production. Sandbox is the debug environment, and production is the production environment.
  • Replace {INTL_DMM_APP_ID} with the DMM App ID of the game.
  • Replace {INTL_DMM_CONSUMER_KEY} with the DMM Consumer Key of the game.
  • Replace {INTL_DMM_CONSUMER_SECRET} with the DMM Consumer Secret of the game.
  • The setting rules for the {INTL_DMM_REDIRECT_URL} value are as follows:
    1. Delete all periods in the software package name. For example, the package name com.INTL.game becomes the string comINTLgame.
    2. The string obtained by the above rule is changed from uppercase to lowercase. For example, in the above example, the string becomes comintlgame.
    3. Then, ://auth is added at the end, for example, comintlgame://auth.
  1. Complete Gradle configuration.

In mainTemplate.gradle, add DMM_LOGIN_ACTIVITY_DATA_SCHEME.

android {
defaultConfig {
manifestPlaceholders = [
"DMM_LOGIN_ACTIVITY_DATA_SCHEME":"{INTL_DMM_LOGIN_ACTIVITY_DATA_SCHEME}"
]
}
}

The setting rules for this {INTL_DMM_LOGIN_ACTIVITY_DATA_SCHEME} value are as follows:

  1. Delete all periods in the software package name. For example, the package name com.INTL.game becomes the string comINTLgame.
  2. The string obtained by the above rule is changed from uppercase to lowercase. For example, in the above example, the string becomes comintlgame.

Step 2: Add DMM login

  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.DMM); 
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

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.