Oculus をアイデンティティプロバイダーとして設定する
注釈:本資料はAI技術を用いて翻訳されています。
概要
このガイドは、認証済みの Oculus 開発者が Oculus アカウントを AccelByte Gaming Services (AGS) に接続するのに役立ちます。Oculus サービス内で追加機能を設定する必要がある場合があります。Oculus サービスの設定に関する詳細情報については、Oculus の担当者に連絡し、Oculus のドキュメントを確認することをお勧めします。
このガイドは公開利用を目的としており、機密性の関係で限られた情報のみを含んでいます。まず完全な機密ガイドを参照することをお勧めします。ガイドのコピーをリクエストするには、AccelByte のテクニカルプロデューサーにお問い合わせください。
目標
- AGS SDK を使用して、ゲームで Oculus 認証方式を有効にします。
- AGS Player Portal を使用して、パブリッシャーウェブサイトで Oculus 認証方式を有効にします。
前提条件
Web ログイン統合
- 認証済みの Oculus Developer アカウントが必要です。
- 認証を設定し、権限を管理するための AGS Admin Portal アカウントが必要です。
- まだ行っていない場合は、Player Portal と Launcher のパブリッシャー名前空間を設定してください。
- Player Portal が必要です。
インゲームログイン統合
- 認証済みの Oculus Developer アカウントが必要です。
- Unreal Engine の場合、OnlineSubsystem Oculus プラグインを有効化する必要があります。
- Unity の場合、Oculus Unity Integration が必要です。これは Oculus Integration | Integration | Unity Asset Store で見つけることができます。
- 認証を設定し、権限を管理するための AccelByte Admin Portal アカウントが必要です。
- まだ行っていない場合は、ゲーム用のゲーム名前空間を設定してください。
- 最新バージョンの AccelByte Game SDK がインポートされた Unity または Unreal Engine のゲームプロジェクトが必要です。
- AGS Identity and Access Management (IAM) クライアントに関する知識が必要です。
Oculus Meta を設定する
Oculus Meta アプリケーションを設定する
Oculus 開発者アカウントで Oculus Meta アプリケーションを設定します。Oculus Meta の Create an App Page ガイドに従ってください。
Oculus Meta のプラットフォーム機能リクエスト
アプリケーションの作成が完了したら、ユーザー ID、ユーザープロフィール、アバターなどの特定のユーザーデータへのアクセスを取得するために、データ使用チェックアップをリクエストします。Oculus Meta の Data User Checkup ガイドにある Submitting a DUC Guide の手順に従ってください。
Oculus Developer Portal での設定に問題がある場合は、カスタマーサポートに連絡し、AccelByte から利用可能なガイドのコピーをリクエストしてください。
Oculus ログイン方式を設定する
Web ログイン
Web ログイン統合は現在 AGS Public Cloud では利用できず、AGS Private Cloud でのみサポートされています。
プレイヤーが Oculus アカウントを使用して Player Portal にログインできるようにするには、次の手順に従います。
-
AGS Admin Portal で、パブリッシャー名前空間に移動します。
-
サイドバーメニューで、Foundations > 3rd Party Integrations > Auth & Account Linking に移動します。
-
Auth & Account Linking ページで、+ Add New ボタンをクリックします。

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

-
Create Configuration ポップアップが表示されます。必要な情報を入力し、Create をクリックします。
- Client ID フィールドに、Oculus App ID を入力します。
- Client Secret フィールドに、Oculus App Secret を入力します。
- Organization ID フィールドに、Oculus Organization ID を入力します。
- Redirect URI フィールドに、
<BASE_URL>/auth/platforms/oculuswebを入力します。<BASE_URL>をドメインアドレスに置き換えます(例:https://development.accelbyte.io)。

-
詳細ページにリダイレクトされます。詳細ページで Activate をクリックし、ポップアップで Activate をクリックします。

インゲームログイン
プレイヤーがインゲームから Oculus アカウントを使用してログインできるようにするには、次の手順に従います。
-
AGS Admin Portal で、ゲーム名前空間に移動します。
-
サイドバーメニューで、Foundations > 3rd Party Integrations > Auth & Account Linking に移動します。
-
Auth & Account Linking ページで、+ Add New ボタンをクリックします。

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

-
Create Configuration ポップアップが表示されます。必要な情報を入力し、Create をクリックします。設定の詳細ページが表示されます。
- Client ID フィールドに、Oculus App ID を入力します。
- Client Secret フィールドに、Oculus App Secret を入力します。
-
詳細ページで Activate をクリックし、ポップアップで Activate をクリックします。

IAM クライアントを作成する
IAM クライアントは、対象プラットフォームでリリースしたいゲームクライアントを表すものです。IAM クライアントの詳細については、アプリケーションのアクセス制御を管理するを参照してください。
インゲームログイン
セットアップはゲームエンジンごとに異なります。使用しているゲームエンジンに適用される手順に従ってください。
- Unreal Engine Instructions
- Unity Engine Instructions
Unreal インゲームログイン統合
Oculus を AccelByte SDK でのサインインと統合することで、プレイヤーが Oculus の認証情報でゲームにログインできるようになります。
Unreal Engine の準備と設定
依存関係を追加する
-
Build.csファイルに、OnlineSubsystem、OnlineSubsystemOculus、LibOvrPlatformというパブリック依存関係モジュールを追加します。これらの依存関係は、プロジェクトが Unreal Engine の Oculus オンラインサブシステムを使用するために必要です。public ABThirdPartyLogin(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "OnlineSubsystemUtils",
"OnlineSubsystemOculus","LibOVRPlatform",
"Sockets", "Networking", "InputCore", "AccelByteUe4Sdk", "Json", "JsonUtilities", "Http", "WebSockets"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
PrivateDependencyModuleNames.Add("OnlineSubsystem"); -
TutorialProject.Target.csとTutorialProjectEditor.Target.csの中にもOnlineSubsystemOculusを追加する必要があります。public ABThirdPartyLoginTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemOculus" } );
}public ABThirdPartyLoginEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "ABThirdPartyLogin", "OnlineSubsystem", "AccelByteUe4Sdk", "OnlineSubsystemOculus" } );
}
Oculus 用の Unreal Engine プロジェクト設定
DefaultEngine.ini ファイルの中に、Oculus 設定の変数をいくつか追加する必要があります。プロジェクトを開くにはこの設定が必要です。デフォルトでは、Oculus は自動的に初期化します。Rift アプリを開発する場合は、RiftAppId=[YourAppId] を使用していることを確認してください。それ以外の場合は、OculusAppId=[YourAppId] を使用できます。
[OnlineSubsystem]
DefaultPlatformService=Oculus
[OnlineSubsystemOculus]
bEnabled=true
RiftAppId=[YourAppId]
Unreal Engine のサンプルコード実装
AGS SDK を使用してゲームに Oculus ログイン統合を組み込む方法を説明します。ここでのロジックは、プレイヤーが Oculus でログインした際にそのログインをオーバーライドし、AGS プラットフォームを利用して SDK がアクセスできるサービスを提供するというものです。
このプロジェクトは Oculus をプラットフォームとして使用しているため、プレイヤーは Oculus の認証情報でログインできます。
スニペットで使用されている AccelByteOnlineSubsystemPtr を取得するには、このガイドに従ってください。
-
Oculus のエンタイトルメントチェックに合格したら、platform_token を取得するためにオンラインアイデンティティインターフェースの関数を必ず呼び出してください。
const IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if (OnlineSubsystem == nullptr)
{
FString Message = TEXT("Cannot login with no online subsystem set!");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
OnActionInfoUpdated.Broadcast(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);
OnActionInfoUpdated.Broadcast(Message);
return;
} -
システムが platform_token を取得すると、そのトークンを使用して AccelByte の
loginWithOtherPlatformAPI を呼び出します。コードは次のようになります。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)
{
auto OculusUserId = OnlineIdentity->GetUniquePlayerId(0);
auto GenAuth = OnlineIdentity->GetAuthToken(LocalPlayer->GetControllerId());
const FString PlatformToken = (TEXT("%s:%s"), OculusUserId, GenAuth);
UE_LOG(LogTemp, Warning, TEXT("PlatformToken : %s"), *PlatformToken);
OnActionInfoUpdated.Broadcast(FString::Printf(TEXT("PlatformToken : %s"), *PlatformToken));
auto ApiClient = AccelByteOnlineSubsystemPtr->GetApiClient(TEXT("YOUR_KEY"));
auto UserApi = ApiClient->GetUserApi().Pin();
UserApi->LoginWithOtherPlatform(EAccelBytePlatformType::Oculus, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
UE_LOG(LogTemp, Warning, TEXT("Request LoginWithOtherPlatform"));
OnActionInfoUpdated.Broadcast(TEXT("Request LoginWithOtherPlatform"));
}
});
OnlineIdentity->AddOnLoginCompleteDelegate_Handle(LocalPlayer->GetControllerId(), NativeLoginComplete);
const bool bWaitForDelegate = OnlineIdentity->Login(LocalPlayer->GetControllerId(), FOnlineAccountCredentials());
if (!bWaitForDelegate)
{
FString Message = TEXT("The online subsystem couldn't login");
UE_LOG(LogTemp, Warning, TEXT("%s"), *Message);
OnActionInfoUpdated.Broadcast(Message);
}注記Oculus 認証の
platform_tokenは<oculus_user_id>:<nonce_value>です。このコードで正しいプラットフォームを呼び出していることを確認してください:
EAccelBytePlatformType::Oculus。UserApi->LoginWithOtherPlatform(EAccelBytePlatformType::Oculus, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
サンプルコードのテスト
起動引数
エディタでプロジェクトを実行して起動するか、コマンドプロンプトまたは Powershell でこの実行コマンドを使用します。
"[[PathToUE5Folder]]\Epic Games\UE_5.0\Engine\Binaries\Win64\UnrealEditor.exe]" "[PathToProjectFolder]\TestingUnreal\ABThirdPartyLogin\ABThirdPartyLogin.uproject" -skipcompile -game
以下の画像は、Oculus アカウントを使用してテストアプリへのログインに成功した様子を示しています。

Unity インゲームログイン統合
Oculus アカウントを AccelByte SDK でのサインインと統合すると、プレイヤーは Oculus の認証情報を使用してゲームにログインできます。
Unity の準備と設定
-
Unity プロジェクトに AccelByte Unity SDK を追加します。
-
Unity Asset Store から Unity Oculus Integration Asset を追加します。
-
Unity アセットをインストールし、リストに追加していることを確認してください。
Unity のサンプルコード実装
AccelByte Unity SDK と Oculus Integration Asset を追加し、次の手順に従います。
-
空のスクリプトを作成し、名前を付けます。
-
Editor でスクリプトを開き、ユーザー ID と nonce を取得する前にエンタイトルメントをチェックする、次のコードを追加します。
void Awake()
{
try
{
Core.Initialize();// getting oculus APP ID
Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);// if entitlement pass will automatically return callback
Users.GetLoggedInUser().OnComplete(getUserCallback);//to generate userId
Users.GetUserProof().OnComplete(userProofCallback);//to generate UserNonce
}
catch (UnityException e)
{
Debug.LogError("Platform failed to initialize due to exception.");
Debug.LogException(e);
// Immediately quit the application.
UnityEngine.Application.Quit();
}
}
// Called when the Meta Quest Platform completes the async entitlement check request and a result is available.
void EntitlementCallback(Message msg)
{
if (msg.IsError) // User failed entitlement check
{
// Implements a default behavior for an entitlement check failure -- log the failure and exit the app.
Debug.LogError("You are NOT entitled to use this app.");
UnityEngine.Application.Quit();
}
else // User passed entitlement check
{
// Log the succeeded entitlement check for debugging.
Debug.Log("You are entitled to use this app.");
LoginStatus.text = "You are entitled to use this app, Please Login";
}
}
void getUserCallback(Message<Models.User> msg)
{
if (!msg.IsError)
{
Models.User user = msg.Data;
userId = user.ID.ToString();
Debug.Log(
$"user : {user} ");
}
else
{
Models.Error error = msg.GetError();
}
}
void userProofCallback(Message<UserProof> msg)
{
if (!msg.IsError)
{
UserProof userNonce = msg.Data;
nonce = userNonce.Value;
Debug.Log(
$"userNonce : {userNonce} ");
}
else
{
Models.Error error = msg.GetError();
}
} -
Oculus Tab > Platform - Edit Setting を開き、App Id フィールドに入力します。
-
スクリプトは続けてこの関数を実行します。
public void OnLoginClick()
{
OculusLoginButton.interactable = false;
LoginStatus.text = "Logging in...";
var apiClient = AccelByteSDK.GetClientRegistry().GetApi();
var user = apiClient.GetUser();
// oculus token
string oculusToken = userId + ":" + nonce;
Result<TokenData, OAuthError> loginResult = null;
user.LoginWithOtherPlatform(PlatformType.Oculus, oculusToken,
(Result<TokenData, OAuthError> loginResult) =>
{
if (loginResult.IsError)
{
//If we error, grab the Error Error and Description to print in the Log
Debug.Log(
$"Login failed : {loginResult.Error.error} Description : {loginResult.Error.error_description}");
//Set the Status Text to display the Error if there is any
LoginStatus.text =
$"Login failed : {loginResult.Error.error} Description : {loginResult.Error.error_description}";
}
else
{
Debug.Log($"Login successful : {loginResult.Value.ToJsonString()}");
LoginStatus.text = $"Success : {loginResult.Value.ToJsonString()} ";
}
//Enable interaction with the Button again
OculusLoginButton.interactable = true;
});
}注記Oculus 認証の
platform_tokenは<oculus_user_id>:<nonce_value>です。 -
この関数は、Oculus プラットフォームタイプを指定して AccelByte エンドポイントにリクエストを送信し、コールバックを返します。
サンプルコードのテスト
これでプロジェクトをビルドして実行できます。以下の画像は、Oculus アカウントを使用したテストアプリでのログイン成功の様子を示しています。


注意
Oculus には 2 種類のユーザー ID があります。
- app scoped id: アプリケーションごとに一意な ID で、同じアプリケーションでもデバイスが異なれば異なる値になります。アプリグルーピングを利用することでこれを回避でき、同じアプリグループ内では新しいユーザーも同じ app scoped id を持ちます。デバイス間でユーザーデータを共有したいゲームの場合は、対象のアプリを同じアプリグループに配置してください。
- organization scoped id: 組織ごとに一意な ID で、同じ組織内の異なるアプリが同一ユーザーを識別できるようにします。
AGS のアカウント連携では、この組織内のアプリに関わらず同じ Oculus アカウントを識別できるように、organization scoped id を使用します。
また、IAP のような一部の機能には app scoped id を利用します。
このエンドポイントを使用して、AGS ユーザー ID から app scoped id を取得できます。
このエンドポイントを使用して、app scoped id から AGS ユーザーアカウントを取得できます。