All Collections
Using the Portal
Authentication – Oculus
Authentication – Oculus

authenticate end-users with Oculus credentials

Jason Liang avatar
Written by Jason Liang
Updated over a week ago

This article elaborates on the basic steps of how to authenticate end-users with their Oculus credentials in a Unity example.

Prerequisites

  • You have set up an Oculus developer account

  • Your Oculus app installed on your test device

For more information about setting up a development environment refer to the Oculus developer site.

User Authentication Flow

brainCloud Portal Setup

Get your Oculus app info on the Oculus developer console

  • Fill out all necessary settings information from there.

  • Click API from the left navigation panel, copy down App ID and App Secret

  • Go back to your organization dashboard, click Test Users from the left side panel, add a new tester, we will use it for this tutorial.

Link your Oculus app into brainCloud

  • Open your app or create a new one from brainCloud development portal, navigate to Design | Core App Info page.

  • Click Oculus under Configure Platforms and paste your Oculus App ID and Oculus App Secret which you copied down from the above step there.

  • Click the Save Changes button when finished.

Create an app on Unity editor

  • Open Unity hub and create a new project.

  • Download and import the latest brainCloud client Unity package to this project. Once imported the plugin correctly, you should find the brainCloud tab appears on the editor menu.

  • Download and import the latest Oculus Unity SDK to this project. You should be able to find the Oculus tab on the editor menu once it was imported.

  • Open brainCloud setting from the tab and log into brainCloud account, then select your team and the app which has Oculus app info configured from the above step.

  • Open Oculus Platform Edit Settings from the tab and link the Oculus app and test user you just created from the above steps.

  • Create some UI elements if you want and initialize brainCloud and Oculus from your script.

  • Functions and its code that linked behind the hood [Oculus Login& bc Auth] are similar to below. Once the test-user is entitled into this Oculus app, from the success callback, retrieve the userId and nonce then pass them to brainCloud Oculus authentication method -- AuthenticateOculus

    void Start()
{
try
{
if (!Oculus.Platform.Core.IsInitialized())
{
Oculus.Platform.Core.Initialize();
}

Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCheckCallback);
}
catch
{
HandleEntitlementCheckResult(false);
}
}

void EntitlementCheckCallback(Message msg)
{
if (msg.IsError == false)
{
Users.GetLoggedInUser().OnComplete(LoggedInUserCallback);
}
}

void LoggedInUserCallback(Message<User> msg)
{
if (msg.IsError == false)
{
oculusUserId = msg.Data.ID.ToString();
Users.GetUserProof().OnComplete(UserProofCallback);
}
}

void UserProofCallback(Message<UserProof> msg)
{
if (msg.IsError == false)
{
string oculusNonce = msg.Data.value;
_bc.AuthenticateOculus(oculusUserId, oculusNonce, true, authSuccess_BCcall, authError_BCcall);
}
}

Run Oculus client app on your device

  • Navigate to the Oculus device setup site, download Oculus App software, install and run it on your compatible gaming device.

  • Run your Unity app on the local Unity editor or the device which is running Oculus App.

  • Now, you should be successfully logged in to brainCloud with the tester credentials!

  • Go back to brainCloud portal open your app, advance to the User Summary page and find the newly authenticated user, click the profiled to open it, you will find the user is logged in with an Oculus credential.

  • Check the user log, you should see the request as follow.

Did this answer your question?