Epic をアイデンティティプロバイダーとして設定する
注釈:本資料はAI技術を用いて翻訳されています。
Overview
このガイドは、検証済みの Epic Games デベロッパーが Epic Games アカウントを AccelByte Gaming Services (AGS) に接続する際の手助けとなることを目的としています。お使いのゲームによっては、ここに記載されていない Epic Games サービス内の追加機能を設定する必要がある場合があります。Epic Games サービスの設定に関する完全な情報については、Epic Games の担当者に直接問い合わせて、Epic Games ドキュメントを確認することをお勧めします。
このガイドは公開利用を目的としており、機密性の理由から限られた情報のみを含んでいます。まずは完全な機密ガイドを参照することをお勧めします。機密ガイドのコピーをリクエストするには、AccelByte のテクニカルプロデューサーに問い合わせてください。
目標
- AccelByte Game SDK を使用して、ゲームで Epic 認証方式を有効にする。
- AccelByte Player Portal を使用して、パブリッシャーの Web サイトで Epic 認証方式を有効にする。
前提条件
Web ログイン統合
- Epic デベロッパーアカウント。
- 認証を設定し権限を管理するための AccelByte Admin Portal アカウント。
- Player Portal と Launcher 用のパブリッシャー Namespace。
- Player Portal。
Web ログイン統合は現在 AGS Public Cloud では利用できず、AGS Private Cloud でのみサポートされています。
インゲームログイン統合
- Epic デベロッパーアカウント。
- Unreal Engine を使用している場合は、UE バージョン 4.27 または 5.0 をインストールする必要があります。
- Unity を使用している場合は、PlayEveryWare/eos_plugin_for_unity が必要です。
- 認証を設定し権限を管理するための AccelByte Admin Portal アカウント。
- ゲーム Namespace。
- AccelByte Game SDK の最新版がインポートされた Unity または Unreal ゲームプロジェクト。
- AGS Identity and Access Management (IAM) クライアントに関する知識。
Epic プロダクトの設定
組織の作成
デベロッパーアカウント配下の組織 (Organization) が必要であり、その組織に検証済みのドメインを追加する必要があります。
Epic によるドメインの検証には多少時間がかかります。
プロダクトブランドの設定
プロダクトのブランド設定、権限、およびリンクされたクライアントを設定します。EOS Epic Account Services のセットアップ方法ガイドに従ってください。
ブランド設定には検証済みのドメインが必要です。ドメインをお持ちでない場合はそのまま進めることもできますが、プレイヤーはログイン時に警告メッセージを受け取ります。詳細については、ドメイン検証のページを参照してください。
クライアントの作成
プロダクト配下にクライアントを作成します。新しいクライアントの追加ガイドに従ってください。
Epic Account Services アプリケーションの作成
アプリケーションを作成します。EOS Epic Account Services アプリケーションのセットアップガイドに従ってください。
- 権限 (Permissions) では、Basic Profile、Online Presence、および Friends List を有効にする必要があります。
- リンクされたクライアント (Linked Clients) では、以前に作成したクライアントを選択します。
Epic デベロッパーポータルでの設定に問題がある場合は、カスタマーサポートに問い合わせて AccelByte からガイドを入手してください。
Epic Games ログイン方式の設定
Web ログイン
-
AGS Admin Portal で、パブリッシャーの namespace に移動します。
-
サイドバーメニューで、Foundations > 3rd Party Integrations > Auth & Account Linking に移動します。
-
Auth & Account Linking ページで、+ Add New ボタンをクリックします。

-
ログイン方式のオプション一覧から、Epic Games を選択します。

-
Epic Games のクライアント認証情報でログイン設定を入力します。Client ID に Epic のクライアント ID を、Client Secret に Epic のクライアントシークレットを入力し、Redirect URI に
<BaseURL>/iam/v3/authenticateを入力します(BaseURL はドメインアドレスです。例:https://prod.gamingservices.accelbyte.io)。その後、Create ボタンをクリックします。
-
有効化します。

試してみる
- Player Portal に進み、Login ボタンをクリックします。

- Epic Games アイコンをクリックします。見つからない場合は、More login options をクリックできます。

- Login with Epic Games をクリックします。

- Epic Games の Web ログインページにリダイレクトされ、そこで Epic の認証情報を入力して進めます。これで完了です。必要な手順を完了しました。

現在、プレイヤーは自分の Epic アカウントを既存の AccelByte アカウントにリンクするか、新しいアカウントにリンクするかを求められます。AccelByte では、プレイヤーがヘッドレスアカウントで Player Portal に直接ログインできるように、この動作を設定可能にする取り組みが進行中です。
インゲームログイン
-
AGS Admin Portal で、ゲームの namespace に移動します。
-
サイドバーメニューで、Foundations > 3rd Party Integrations > Auth & Account Linking に移動します。
-
Auth & Account Linking ページで、+ Add New ボタンをクリックします。

-
ログイン方式のオプション一覧から、Epic Games を選択します。

-
Epic Games のクライアント認証情報でログイン設定を入力します。Client ID に Epic のクライアント ID を、Client Secret に Epic のクライアントシークレットを入力し、Redirect URI に
http://127.0.0.1(localhost)を入力します。その後、Create ボタンをクリックします。
-
有効化します。

Epic Games 用の IAM クライアントを作成する
IAM クライアントとは、対象のプラットフォームでリリースしたいゲームクライアントを表すものです。IAM クライアントの詳細については、アプリケーションのアクセス制御を管理するを参照してください。
- Unreal Engine Instructions
- Unity Instructions
Unreal インゲームログイン統合
AccelByte SDK を使用してゲームのサインインを統合することで、プレイヤーが自分の Epic 認証情報を使ってゲームにログインできるようにします。
Unreal の準備と設定
依存関係の追加
まず、パブリック依存モジュールである OnlineSubsystem と OnlineSubsystemEOS を <YourProject>.Build.cs ファイルに追加する必要があります。これらは、Unreal Engine 内からオンラインサブシステム EOS を使用するようにプロジェクトを統合するために必要なすべての依存関係です。
public ABThirdPartyLogin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" , "AccelByteUe4Sdk", "Slate", "SlateCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "Json", "OnlineSubsystem", "OnlineSubsystemEOS", "HTTP" });
}
<YourProject>.Target.cs の内部に OnlineSubsystemEOS を追加します。
public ABThirdPartyLoginTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemEOS" } );
}
<YourProject>.Target.cs および <YourProjectEditor>.Target.cs ファイルの内部に OnlineSubsystemSteam を追加します。
public ABThirdPartyLoginEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemEOS" } );
}
Epic Games ログイン用の Unreal Engine プロジェクト設定
DefaultEngine.ini ファイル内に、Epic の設定用にいくつかの変数を追加する必要があります。この設定は、プロジェクトを開いたときに Epic Online Service が自動的に開始されるようにするために必要です。
Unreal Engine に Online Subsystem EOS を使用するよう指示するには、次の設定を追加します。
[OnlineSubsystem]
DefaultPlatformService=EOS
アプリケーションで EOS Online Subsystem を使用することを Unreal Engine に伝えたので、次に以下の設定を追加して OnlineSubsystemEOS モジュールを設定する必要があります。
[OnlineSubsystemEOS]
bEnabled=true
Epic Developer Portal から取得した値に基づいて、以下の値を入力できます。
[/Script/OnlineSubsystemEOS.NetDriverEOS]
bIsUsingP2PSockets=true
[/Script/OnlineSubsystemEOS.EOSSettings]
CacheDir=CacheDir
DefaultArtifactName=YOUR Product Name
TickBudgetInMilliseconds=0
bEnableOverlay=True
bEnableSocialOverlay=True
bShouldEnforceBeingLaunchedByEGS=False
TitleStorageReadChunkLength=0
+Artifacts=(ArtifactName="[Your Product Name]",
ClientId="[Your Client ID]",//This ID should start with "xyz" as the first 3 characters
ClientSecret="[Your Client Secret]",//This is the password that is used to verify your Client ID
ProductId="[Your Product ID]",//The EOS SDK uses this ID to identify your product
SandboxId="[Your Sandbox ID]",//The artifact belongs to the sandbox with this ID value.
DeploymentId="[Your Deployment ID]",//Deployment IDs differ for each artifact
EncryptionKey="[Your Encyption Key]")//When you upload data to an EOS service, this 64-byte hexadecimal string is used to encrypt it
bUseEAS=True
bUseEOSConnect=True
bMirrorStatsToEOS=True
bMirrorAchievementsToEOS=True
bUseEOSSessions=True
bMirrorPresenceToEAS=True
zUnreal Engine Project Setting for AccelByte Gaming Services
Add your AccelByte credentials here in DefaultEngine.ini
[/Script/AccelByteUe4Sdk.AccelByteSettings]
ClientId=<Your IAM_Client_Id>
ClientSecret=<Your IAM_Client_Secret>
Namespace=<Your Namespace>
PublisherNamespace=<Your Publisher Namespace>
RedirectURI=
BaseUrl="https://prod.gamingservices.accelbyte.io"
AppId=133xxx
IamServerUrl="https://prod.gamingservices.accelbyte.io/iam"
PlatformServerUrl="https://prod.gamingservices.accelbyte.io/platform"
Unreal Engine サンプルコードの実装
次に、以下のサンプルコードを使用して、ゲームに Epic 認証方式を実装する方法を説明します。
IOnlineSubsystem は DefaultEngine.ini で定義された DefaultPlatformService の値を読み取ります。IdentityInterface は、ユーザーアカウントに関連するこれらのサービスとのやり取りを管理し、ユーザー認証とアクセストークンの取得を可能にします。操作が成功すると、AccelByte SDK の LoginWithOtherPlatform 関数が、Identity Interface から取得した認証トークンを使用してサードパーティプラットフォームのログインを処理します。
スニペットで使用されている AccelByteOnlineSubsystemPtr を取得するには、このガイドに従ってください。
FOnlineAccountCredentials Credentials;
Credentials.Id = FString();
Credentials.Token = FString();
Credentials.Type = FString("accountportal");
UE_LOG(LogTemp, Warning, TEXT("%s"), TEXT("Begin Login"));
const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if (OnlineSubsystem == nullptr)//will get active OSS Platform Service
{
FString Message = TEXT("Cannot login with no online subsystem set!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
const IOnlineIdentityPtr OnlineIdentity = OnlineSubsystem->GetIdentityInterface();
if (!OnlineIdentity.IsValid())
{
FString Message = TEXT("Could not retrieve identity interface from native subsystem.");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
APlayerController* MyPlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);;
const ULocalPlayer* LocalPlayer = Cast<ULocalPlayer>(MyPlayerController->Player);
if (LocalPlayer == nullptr)
{
FString Message = TEXT("Can only login with native platform for local players");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
return;
}
auto ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient(TEXT("YOUR_KEY"));
auto UserApi = ApiClient->GetUserApi().Pin();
const FVoidHandler OnLoginSuccessDelegate = FVoidHandler::CreateLambda([&]() {
FAccountUserData AccountUserData = ApiClient->CredentialsRef->GetAccountUserData();
//if Success will return some user credential
FString AccountUserDataString;
FJsonObjectConverter::UStructToJsonObjectString(AccountUserData, AccountUserDataString);
FString Message = FString::Printf(TEXT("Login to AB Service Success : %s"), *AccountUserDataString);
});
const FErrorHandler OnLoginErrorDelegate = FErrorHandler::CreateLambda([=](int32 ErrorCode, const FString& ErrorMessage) {
FString Message = FString::Printf(TEXT("Error Login to AB Service : %s"), *ErrorMessage);//Failed Login to AB Service
});
const FOnLoginCompleteDelegate NativeLoginComplete = FOnLoginCompleteDelegate::CreateLambda([=]
(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error) {
UE_LOG(LogTemp, Warning, TEXT("OnLoginComplete %s : %s"), bWasSuccessful ? TEXT("Success") : TEXT("Fail"), *Error);
FString Message = FString::Printf(TEXT("OnLoginComplete %s : %s"), bWasSuccessful ? TEXT("Success") : TEXT("Fail"), *Error);
OnActionInfoUpdated.Broadcast(Message);
if (bWasSuccessful)
{
const FString PlatformToken = OnlineIdentity->GetAuthToken(LocalPlayer->GetControllerId());
UE_LOG(LogTemp, Warning, TEXT("PlatformToken : %s"), *PlatformToken);
OnActionInfoUpdated.Broadcast(FString::Printf(TEXT("PlatformToken : %s"), *PlatformToken));//Will Obtained Auth Ticket from OnlineIdentity
UserApi->LoginWithOtherPlatform(EAccelBytePlatformType::EpicGames, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
UE_LOG(LogTemp, Warning, TEXT("Request LoginWithOtherPlatform"));
OnActionInfoUpdated.Broadcast(TEXT("Request LoginWithOtherPlatform"));
}//this method will hitting the AccelByte endpoint and will return value after success
});
OnlineIdentity->AddOnLoginCompleteDelegate_Handle(LocalPlayer->GetControllerId(), NativeLoginComplete);
const bool bWaitForDelegate = OnlineIdentity->Login(LocalPlayer->GetControllerId(), Credentials);
if (!bWaitForDelegate)
{
FString Message = TEXT("The online subsystem couldn't login");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
}
FString Message = TEXT("Sending login request to native subsystem!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
Epic Games 認証における platform_token は Access Token/Auth Code です。
このコードをプロジェクトに追加した後、プロジェクトをコンパイル、ビルド、実行します。これで完了です。
サンプルコードのテスト
以下の画像は、Epic アカウントを使用してテストアプリに正常にログインできた例を示しています。

Unity インゲームログイン統合
AccelByte SDK を使用して Epic Game のサインインを統合することで、プレイヤーが自分の Epic 認証情報を使ってログインできるようにします。
Unity の準備と設定
Epic Games ログイン用の Unity プロジェクト設定
SDK Config を開く方法の詳細については、SDK のインストールと設定を参照してください。その後、AGS Admin Portal の値に基づいて各属性を入力し、設定を保存します。
Unity サンプルコードの実装
このサンプルコードの実装では、Epic Game SDK のラッパーとして、オープンソースの PlayEveryWare の Epic Online Service Plugin を使用します。
このプラグインを機能させるには、プラグインとタイムティッカーのアタッチ処理を Awake メソッドと Update メソッドの中に配置するようにしてください。
float platformTickTimer = 0f;
const float platformTickInterval = 0.1f;
// In the editor, make sure to dynamically load and unload the SDK between play sessions.
// This initializes the SDK each time the game is run in editor.
#if UNITY_EDITOR
[DllImport("Kernel32.dll")]
private static extern IntPtr LoadLibrary(string lpLibFileName);
[DllImport("Kernel32.dll")]
private static extern int FreeLibrary(IntPtr hLibModule);
[DllImport("Kernel32.dll")]
private static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
private IntPtr libraryPointer;
#endif
private void Awake()
{
#if UNITY_EDITOR
var libraryPath = "Assets/" + Epic.OnlineServices.Config.LibraryName;
libraryPointer = LoadLibrary(libraryPath);
if (libraryPointer == IntPtr.Zero)
{
throw new Exception("Failed to load library" + libraryPath);
}
Bindings.Hook(libraryPointer, GetProcAddress);
#endif
}
private void OnApplicationQuit()
{
if (platformInterface != null)
{
platformInterface.Release();
platformInterface = null;
PlatformInterface.Shutdown();
}
#if UNITY_EDITOR
if (libraryPointer != IntPtr.Zero)
{
Bindings.Unhook();
// Free until the module ref count is 0
while (FreeLibrary(libraryPointer) != 0) { }
libraryPointer = IntPtr.Zero;
}
#endif
}
// Calling tick on a regular interval is required for callbacks to work.
private void Update()
{
if (platformInterface != null)
{
platformTickTimer += UnityEngine.Time.deltaTime;
if (platformTickTimer >= platformTickInterval)
{
platformTickTimer = 0;
platformInterface.Tick();
}
}
}
その EOS Plugin の Login メソッドを使用して Epic トークンを生成できます。プラグインが正しく初期化されていることも確認してください。
private void GetEpicToken(string productName
, string productVersion
, string productId
, string sandboxId
, string deploymentId
, string epicClientId
, string epicClientSecret
, LoginCredentialType credentialType
, string credentialId
, string credentialToken
, Action<string> onGetEpicTokenFinished)
{
var initializeOptions = new InitializeOptions()
{
ProductName = productName,
ProductVersion = productVersion
};
var initializeResult = PlatformInterface.Initialize(ref initializeOptions);
if (initializeResult != Epic.OnlineServices.Result.Success)
{
Debug.LogError("Failed to initialize platform: " + initializeResult);
return;
}
var options = new Options()
{
ProductId = productId,
SandboxId = sandboxId,
DeploymentId = deploymentId,
ClientCredentials = new ClientCredentials()
{
ClientId = epicClientId,
ClientSecret = epicClientSecret
}
};
PlatformInterface platformInterface = PlatformInterface.Create(ref options);
if (platformInterface == null)
{
Debug.LogError("Failed to create platform");
return;
}
var loginOptions = new LoginOptions()
{
Credentials = new Credentials()
{
Type = credentialType,
Id = credentialId,
Token = credentialToken
},
// Change these scopes to match the ones set up on your product on the Developer Portal.
ScopeFlags = Epic.OnlineServices.Auth.AuthScopeFlags.BasicProfile |
Epic.OnlineServices.Auth.AuthScopeFlags.FriendsList |
Epic.OnlineServices.Auth.AuthScopeFlags.Presence
};
string authCode = string.Empty;
platformInterface.GetAuthInterface().Login(ref loginOptions, null,
(ref LoginCallbackInfo loginCallbackInfo) =>
{
if (loginCallbackInfo.ResultCode == Epic.OnlineServices.Result.Success)
{
Debug.Log("Epic Login succeeded");
CopyUserAuthTokenOptions tokenOptions = new CopyUserAuthTokenOptions();
Token? token = null;
platformInterface.GetAuthInterface().CopyUserAuthToken(ref tokenOptions, loginCallbackInfo.LocalUserId, out token);
if (token == null)
{
Debug.Log("Could not get token");
return;
}
authCode = token.Value.AccessToken;
}
else if (Common.IsOperationComplete(loginCallbackInfo.ResultCode))
{
Debug.Log("Epic Login failed: " + loginCallbackInfo.ResultCode);
authCode = loginCallbackInfo.ResultCode.ToString();
}
onGetEpicTokenFinished?.Invoke(authCode);
});
}
Epic Games 認証における platform_token は Access Token/Auth Code です。
AccelByte IAM Service にログインします。
private void LoginAccelByteEpicPlatform(string productName
, string productVersion
, string productId
, string sandboxId
, string deploymentId
, string epicClientId
, string epicClientSecret
, LoginCredentialType credentialType
, string credentialId
, string credentialToken)
{
GetEpicToken(productName, productVersion, productId, sandboxId, deploymentId, epicClientId, epicClientSecret, credentialType, credentialId, credentialToken, epicToken =>
{
if (string.IsNullOrEmpty(epicToken))
{
Debug.LogError("Epic Token is empty");
return;
}
AccelByte.Api.User user = AccelByteSDK.GetClientRegistry().GetApi().GetUser();
user.LoginWithOtherPlatform(AccelByte.Models.PlatformType.EpicGames, epicToken, OnLoginWithEpicDone);
});
}
private void OnLoginWithEpicDone(Result<TokenData, OAuthError> loginResult)
{
if (loginResult.IsError)
{
Debug.Log($"Login failed, Error: {loginResult.Error.error}, Description {loginResult.Error.error_description}");
}
else
{
Debug.Log("Login success");
}
}
Login Handler Script をプロジェクトに追加した後、プロジェクトをコンパイルできます。
サンプルコードのテスト
これで、プロジェクトをビルドして実行できます。以下の画像は、Epic アカウントを使用してテストアプリに正常にログインできた例を示しています。

ログインを完了するには、Epic Games のログイン認証情報を入力します。
