Android
This article guides you through setting up Kakao as an identity provider, enabling your Android game to access Player Network authentication services.
Prerequisites
1. Set up the Kakao app on Kakao Developers
1. Create a Kakao app
Go to Kakao Developers to register for a developer account, and contact an admin on Player Network to authenticate the business account.
Go to Kakao Developers.
Create an app and enter the basic app info.
Enter app configurations for the Android platform.
If clicking KakaoTalk message requires redirecting the user to a URL, register the URL domain to the Site domain in the Web platform.
2. Enable Kakao login for the app
Set Kakao Login Activation state to ON.
Add
https://kauth.kakao.com/oauth
in the Redirect URI.Set the login permission and scope based on the following image.
For example, the scope to access nickname and profile image after login.
3. Retrieve app information
Go to My Application > App Settings > Summary to view basic application information.
- Create an account for Player Network Console.
- Create a new project for your game, or join an existing one.
- Download the SDK.
- Integrate the SDK.
- Add Kakao as an authentication method for your project on Player Network Console.
Step 1: Configure the SDK for Kakao login
JDK:JDK8+
AndroidSdk:Android12.0(API31)
OS:Android 5.0, API 21 or higher supported
Gradle Version:6.1.1+
Android Gradle Plugin Version:3.6.1+
If the minSdkVersion does not match, add the following code in AndroidManifest.xml
:
<uses-sdk tools:overrideLibrary="com.kakaogame.kakao,com.kakao.sdk.v2.story,com.kakao.sdk.v2.partner.user,
com.kakao.sdk.v2.user,com.kakao.sdk.v2.partner.auth,com.kakao.sdk.v2.partner.talk,
com.kakao.sdk.v2.talk,com.kakao.sdk.v2.auth,com.kakaogame,com.kakaogame.common,com.kakao.sdk.v2.partner,
com.kakao.sdk.v2.link,com.kakao.sdk.v2.template,com.kakao.sdk.v2.network,
com.kakao.sdk.v2.common,com.kakao.sdk.v2.partner.friend" />
In the
kakao_game_sdk_configuration.xml
file underAssets/Plugins/Android/INTLKaKao.androidlib/assets
.<?xml version="1.0" encoding="UTF-8"?>
<configuartion-list>
<configuration key="appId" value="" />
<configuration key="appSecret" value="" />
<configuration key="debugLevel" value="verbose" />
</configuartion-list>- Set
appId
with the App ID in the Retrieve Kakao Info. - Set
appSecret
with the Native app key in the Retrieve Kakao Info.
- Set
In the
AndroidManifest
file, add the following code in the configured launch interface to ensure that players can open the game after clicking the app info in the KakaoTalk message.<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="kakao{INTL_KAKAO_APP_SECRET}" android:host="kakaolink"
tools:ignore="AppLinkUrlError" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="kakao{INTL_KAKAO_APP_SECRET}" android:host="kakaostory"
tools:ignore="AppLinkUrlError" />
</intent-filter>Replace
{INTL_KAKAO_APP_SECRET}
with the Native app key in the Retrieve Kakao Info.Open the project's INTLConfig.ini:
[Android LifeCycle]
LIFECYCLE = KaKao
[KaKao]
KAKAO_APP_SECRET = {INTL_KAKAO_APP_SECRET}
KAKAO_APP_ID = {INTL_KAKAO_APP_ID}- Replace
{INTL_KAKAO_APP_SECRET}
with the Native app key in the Retrieve Kakao Info. - Replace
{INTL_KAKAO_APP_ID}
with the App ID in the Retrieve Kakao Info.
- Replace
Step 2: Add Kakao login
Please verify web login on browsers supporting Chrome Custom Tabs such as Chrome.
Add an observer to handle authentication callbacks.
- Unity
- Unreal Engine
// 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";
}
}C++ Event Handling (above v1.15)
//configure callback
FINTLAuthEvent authEvent;
authEvent.AddUObject(this, &OnAuthResult_Implementation);
UINTLSDKAPI::SetAuthResultObserver(authEvent);
// Remove callbacks
UINTLSDKAPI::GetAuthResultObserver().Clear();void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Unreal Event Handling
void OnAuthResult_Implementation(FINTLAuthResult ret)
{
UE_LOG(LogTemp, Warning, TEXT("MethodID: %d"), ret.MethodId);
}Call the
AutoLogin
method.- Unity
- Unreal Engine
INTLAPI.AutoLogin();
UINTLSDKAPI::AutoLogin();
Call the
Login
method to ask for user input if auto-login fails.- Unity
- Unreal Engine
INTLAPI.Login(INTLChannel.KaKao);
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelKaKao);
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.