Epic をアイデンティティプロバイダーとして設定する
注釈:本資料はAI技術を用いて翻訳されています。
概要
このガイドは、認証されたEpic Gamesデベロッパーが Epic Games アカウントをAccelByte Gaming Services (AGS) に接続するのを支援することを目的としています。ゲームによっては、ここに記載されていないEpic Gamesサービス内の追加機能を設定する必要がある場合があります。Epic Gamesサービスの設定に関する完全な情報については、Epic Gamesの担当者に連絡し、Epic Gamesドキュメントを直接確認することをお勧めします。
このガイドは公開用であり、機密性のため限定的な情報が含まれています。まず完全な機密ガイドを参照することをお勧めします。機密ガイドのコピーをリクエストするには、AccelByteテクニカルプロデューサーにお問い合わせください。
目標
- AccelByte Game SDKを使用してゲームのEpic認証方法を有効にする。
- AccelByte Player Portalを使用してパブリッシャーウェブサイトのEpic認証方法を有効にする。
前提条件
ウェブログイン統合
- Epic Developer Account。
- 認証を設定し、権限を管理するためのAccelByte Admin Portalアカウント。
- Player PortalとLauncher用のパブリッシャーNamespace。
- Player Portal。
ウェブログイン統合は現在AGS Shared Cloudでは利用できず、AGS Private Cloudでのみサポートされています。
ゲーム内ログイン統合
- Epic Developer Account。
- 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) Clientsに関する知識。
Epic Productの設定
組織の作成
Developer Accountの下に組織を作成し、認証済みドメインを追加する必要があります。
Epicがドメインを認証するには時間がかかります。
Product Brandの設定
製品のBrand Settings、Permissions、Linked Clientsを設定します。How to set up EOS Epic Account Services Guideに従ってください。
Brand Settingsには認証済みドメインが必要です。ドメインがない場合は、ドメインなしで続行できますが、プレイヤーはログイン時に警告メッセージを受け取ります。詳細については、Domain Verificationページを参照してください。
クライアントの作成
製品の下にクライアントを作成します。Adding New Clients Guideに従ってください。
Epic Account Services Applicationの作成
アプリケーションを作成します。Setting Up an EOS Epic Account Services Application Guideに従ってください。
- Permissionsでは、Basic Profile、Online Presence、Friends Listを有効にする必要があります。
- Linked Clientsでは、以前に作成したClientを選択します。
Epic Developer Portalでの設定に問題がある場合は、AccelByteのカスタマーサポートに連絡してガイドを入手してください。
Epic Gamesログイン方法の設定
ウェブログイン
-
AGS Admin portalで、パブリッシャーnamespaceに移動します。
-
サイドバーメニューで、Game Setup > 3rd Party Configuration > Auth & Account Linkingに移動します。
-
Login Methodsページで、+ Add Newボタンをクリックします。

-
ログイン方法オプションのリストから、Epic Gamesを選択します。

-
Epic Gamesクライアント認証情報でログイン設定を入力します。Client IDにEpic Client IDを、Client SecretにEpic Client Secretを入力し、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ウェブログインページにリダイレクトされ、Epic認証情報を入力して続行できます。以上です。必要な手順が完了しました。

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

-
ログイン方法オプションのリストから、Epic Gamesを選択します。

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

Epic Games用のIAMクライアントの作成
IAMクライアントは、ターゲットプラットフォームでリリースするゲームクライアントの表現です。IAM Clientsの詳細については、Manage access control for applicationsを参照してください。
- Unreal Engine Instructions
- Unity Instructions
Unrealゲーム内ログイン統合
AccelByte SDKを使用してゲームサインインを統合し、プレイヤーがEpic認証情報を使用してゲームにログインできるようにすることができます。
Unreal準備と設定
依存関係の追加
まず、<YourProject>.Build.csファイルに公開依存関係モジュールOnlineSubsystemとOnlineSubsystemEOSを追加する必要があります。これらは、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
Unreal EngineにアプリケーションでEOS Online Subsystemを使用することを伝えたので、次の設定を追加して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
AccelByte Gaming Services用のUnreal Engineプロジェクト設定
DefaultEngine.iniにAccelByte認証情報を追加します
[/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 FCustomErrorHandler OnLoginErrorDelegate = FCustomErrorHandler::CreateLambda([=](int32 ErrorCode, const FString& ErrorMessage, const FJsonObject& ErrorObject) {
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);
platform_token(Epic Games認証用)はAccess Token/Auth Codeです
このコードをプロジェクトに追加した後、プロジェクトをコンパイル、ビルド、実行します。以上です。
サンプルコードのテスト
以下の画像は、Epicアカウントを使用してテストアプリに正常にログインした様子を示しています。

Unityゲーム内ログイン統合
AccelByte SDKを使用してEpic Gameをサインインに統合し、プレイヤーがEpic認証情報を使用してログインできるようにすることができます。
Unity準備と設定
Epic Gamesログイン用のUnityプロジェクト設定
SDK Configを開く方法の詳細については、Install and configure the SDKを参照してください。次に、AGS Admin Portalの値に基づいて各属性を入力し、設定を保存します。
Unityサンプルコード実装
このサンプルコード実装では、Epic Game SDKのラッパーとしてPlayEveryWareのオープンソースEpic Online Service Pluginを使用します。
Pluginを機能させるには、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();
}
}
}
You can generate an Epic token with the Login method from that EOS Plugin. Make sure that it is also initialized correctly.
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);
});
}
platform_token(Epic Games認証用)はAccess Token/Auth Codeです
AccelByte IAMサービスにログインします。
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スクリプトをプロジェクトに追加した後、プロジェクトをコンパイルできます。
サンプルコードのテスト
これで、プロジェクトをビルドして実行できます。以下の画像は、Epicアカウントとテストアプリを使用した正常なログインを示しています。

Epic Gamesログイン認証情報を入力してログインを完了します。
