Skip to main content

Set up Oculus as an identity provider

Last updated on October 24, 2024

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.

important

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.

note

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:

  1. In the AGS Admin portal, go to your publisher namespace.

  2. On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.

  3. On the Login Methods page, click on the + Add New button.

    Image shows the +Add New button on the Login Methods page

  4. From the list of login method options, select Oculus Web.

    Image shows the Oculus Web button

  5. 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.

    Image shows the Create Configuration form

  6. You will be redirected to the detail page. Click Activate on the detail page, then click Activate on the pop-up.

    Image shows the detail page of the new configuration

In-game login

To enable your players to log in from in-game using their Oculus accounts, follow these steps:

  1. In the AGS Admin portal, go to your game namespace.

  2. On the sidebar menu, go to Game Setup > 3rd Party Configuration > Auth & Account Linking.

  3. On the Auth & Account Linking page, click on the + Add New button.

    Image shows the +Add New button on the Login Methods page

  4. From the list of login method options, select Oculus SDK.

    Image shows the Oculus SDK button

  5. The Create Configuration pop-up will appear. Fill in the required information, then click Create. The details page of the configuration appears.

    • Fill in the Client ID field with your Oculus App ID.
    • Fill in the Client Secret field with your Oculus App Secret.

    Image shows the Create Configuration form

  6. Click Activate on the detail page, then click Activate on the pop-up.

    Image shows the detail page of the new configuration

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 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

  1. Add public dependency modules called OnlineSubsystem, OnlineSubsystemOculus, and LibOvrPlatform to your Build.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");
  2. You also need to add OnlineSubsystemOculus inside TutorialProject.Target.cs and TutorialProjectEditor.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 the AGS platform to provide services our SDK can access.

The project uses Oculus as a platform so players can log in with Oculus credentials.

  1. 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;
    }
  2. 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);
    }
    note

    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.

Image shows sample code for Unreal code testing