Oculus をアイデンティティプロバイダーとして設定する
Overview
This guide helps verified Oculus developers to connect Oculus Accounts to AccelByte Gaming Services (AGS). You may need to set up additional features within Oculus services. For more information about setting up Oculus services, we recommend contacting your Oculus representative and reviewing Oculus documentation.
This guide is intended for public use and contains limited information due to confidentiality. We recommend you refer to the full confidential guide first. Contact your AccelByte Technical Producer to request a copy of the guide.
Goals
- Enable the Oculus authentication method for your game with the AGS SDK.
- Enable the Oculus authentication method for your publisher website with the AGS Player Portal.
Prerequisites
Web login integration
- You must have a verified Oculus Developer account.
- You have an AGS Admin Portal account to set up authentication and manage permissions.
- If you have not done so already, set up a Publisher Namespace for your Player Portal and Launcher.
- You have a Player Portal.
In-game login integration
- You must have a verified Oculus Developer account.
- For Unreal Engine, you need to have the OnlineSubsystem Oculus plugin activated.
- For Unity, you need the Oculus Unity Integration. You can find that in Oculus Integration | Integration | Unity Asset Store.
- You have an AccelByte Admin Portal account to set up authentication and manage permissions.
- If you have not done so already, set up a Game Namespace for your game.
- You have a Unity or Unreal Engine game project with the latest version of the AccelByte Game SDK imported.
- Familiarity with AGS Identity and Access Management (IAM) Clients.
Set up Oculus Meta
Set up Oculus Meta application
Set up the Oculus Meta application on your Oculus developer account. Follow Oculus Meta's Create an App Page guide.
Oculus Meta request platform feature
After you finish creating the application, request a data use checkup to get access to certain user data, such as user ID, user profile, and avatar. Follow the Submitting a DUC Guide steps on Oculus Meta's Data User Checkup guide.
If you have trouble setting up on the Oculus Developer Portal, contact customer support to request a copy of the available guide from AccelByte.
Set up Oculus login method
Web login
To enable your players to log in to your Player Portal using their Oculus accounts, follow these steps:
In the AGS Admin portal, go to your publisher namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Login Methods page, click on the + Add New button.
From the list of login method options, select Oculus Web.
The Create Configuration pop-up will appear. Fill in the required information, then click Create.
- Fill in the Client ID field with your Oculus App ID.
- Fill in the Client Secret field with your Oculus App Secret.
- Fill in the Organization ID field with your Oculus Organization ID.
- Fill in the Redirect URI field with
<BASE_URL>/auth/platforms/oculusweb
. Replace <BASE_URL> with your domain address, e.g.,https://development.accelbyte.io
.
You will be redirected to the detail page. Click Activate on the detail page, then click Activate on the pop-up.
In-game login
To enable your players to log in from in-game using their Oculus accounts, follow these steps:
In the AGS Admin portal, go to your game namespace.
On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.
On the Auth & Account Linking page, click on the + Add New button.
From the list of login method options, select Oculus SDK.
The Create Configuration pop-up will appear. Fill in the required information, then click Create.
- Fill in the Client ID field with your Oculus App ID.
- Fill in the Client Secret field with your Oculus App Secret.
You will be redirected to the detail page. Click Active on the detail page, then click Activate on the pop-up.
Create an IAM client
An IAM client is a representation of the game client that you want to release on your target platform. Learn more about IAM Clients in Manage access control for applications.
In-game login
The setup for each game engine is different. Follow the steps applicable to your game engine.
- Unreal Engine Instructions
- Unity Engine Instructions
Unreal in-game login integration
You can integrate Oculus to sign in with AccelByte SDK to enable your players to log in to games with Oculus credentials.
Unreal Engine preparation and configuration
Add dependency
Add public dependency modules called OnlineSubsystem, OnlineSubsystemOculus, and
LibOvrPlatform
to yourBuild.cs
file. These dependencies are needed for your project to use the Oculus online subsystem from Unreal Engine.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");You also need to add
OnlineSubsystemOculus
insideTutorialProject.Target.cs
andTutorialProjectEditor.Target.cs
.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" } );
}
Unreal Engine project setting for Oculus
Inside your DefaultEngine.ini
file, you need to add several variables of Oculus configuration. You need this configuration to open the project. By default, Oculus initiates automatically. If you develop a rift app, make sure you're using RiftAppId=[YourAppId]
. Otherwise, you can use OculusAppId=[YourAppId]
.
[OnlineSubsystem]
DefaultPlatformService=Oculus
[OnlineSubsystemOculus]
bEnabled=true
RiftAppId=[YourAppId]
Unreal Engine sample code implementation
Learn how to integrate Oculus Login Integration into your game with our SDK. Our logic is to override a player's login when they log in with Oculus and use our platform to provide services our SDK can access.
The project uses Oculus as a platform so players can log in with Oculus credentials.
Ensure you call the online identity function for getting platform_tokens once Oculus does an entitlement pass.
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;
}Once the system retrieves the platform_token, it uses the token to call the AccelByte
loginWithOtherPlatform
API. The code looks like this: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));
FRegistry::User.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);
}注記The
platform_token
for Oculus Authentication is<oculus_user_id>:<nonce_value>
.Ensure you are calling the right platform in this code:
EAccelBytePlatformType::Oculus
.FRegistry::User.LoginWithOtherPlatform(EAccelBytePlatformType::Oculus, PlatformToken, OnLoginSuccessDelegate, OnLoginErrorDelegate);
Sample code testing
Launch arguments
Launch your project by running it in the editor, or use this executable command with the Command Prompt or Powershell.
"[[PathToUE5Folder]]\Epic Games\UE_5.0\Engine\Binaries\Win64\UnrealEditor.exe]" "[PathToProjectFolder]\TestingUnreal\ABThirdPartyLogin\ABThirdPartyLogin.uproject" -skipcompile -game
The image below shows a successful login to our test app using an Oculus account.
Unity in-game login integration
When you integrate your Oculus account to sign in with AccelByte SDK, your players can log in to games using their Oculus credentials.
Unity preparation and configuration
Add AccelByte Unity SDK to your Unity project.
Add the Unity Oculus Integration Asset from the Unity Asset Store.
Ensure you install and list Unity assets.
Unity sample code implementation
Add the AccelByte Unity SDK and Oculus Integration Asset, then follow these steps:
Create and name an empty script.
Open your script in the Editor and add this code, which checks the entitlement before getting the user ID and 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();
}
}Open Oculus Tab > Platform - Edit Setting, then fill in the App Id field.
The script continues to run this function.
public void OnLoginClick()
{
OculusLoginButton.interactable = false;
LoginStatus.text = "Logging in...";
// AccelByte's Multi Registry initialization
apiClient = MultiRegistry.GetApiClient();
//Grab a reference to the current User, even though they have not been logged in yet.
//This also acts as the initialisation point for the whole AccelByte plugin.
user = apiClient.GetApi<AccelByte.Api.User, UserApi>();
// 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;
});
}注記The
platform_token
for Oculus Authentication is<oculus_user_id>:<nonce_value>
.The function sends a request to the AccelByte endpoint with the Oculus platform type and returns a callback.
Sample code testing
Now you can build and run your project. The image below shows a successful login using an Oculus Account and our test app.