Authentication with Oculus
Starting from version 4.0.0, the Oculus login method is fully supported by the plugin. This means that you can now authenticate your users using their Oculus account.
Setting up Oculus App
Before you can start using the Oculus login method, you need to create an Oculus application. To do this, follow these steps:
-
If you don't have a Oculus App yet, create a new one by clicking on the Create New App button in the top right corner and fill in the required information.
-
Now on the left side, click on Requirements and then Data Use Checkup. Two things we need majorly are:
- User Id: This is required to get the unique id of the user.
- User Profile: This is required to get the user's profile informatio like username and user proof.
You may need to apply for these permissions and get them approved by Oculus, but it's almost instant. (Atleast in our case, it takes 5-6 minutes)
-
Once you have the permissions, get the App ID and App Secret from the API page.
Setting up MetaXrPlatform plugin
- Go to Oculus - Unreal Engine 5 Platform SDK (opens in a new tab) and download the MetaXrPlatform plugin.
- After downloading, extract the plugin to the Plugins folder in your Unreal Engine project. [You may need to build the project through Visual Studio to get the plugin working]
- After the plugin is successfully added, go to DefaultEngine.ini and add the following lines:
[OnlineSubsystemOculus]
bEnabled=true
MobileAppId={Your App ID}
EOS Setup
This is the easist part :)
- Go to the Epic Games Developer Portal (opens in a new tab) and select your project.
- Now under Product Settings, click on Identity Providers and press on Add Identity Provider.
- Select Oculus from the list and fill in the App ID and App Secret you got from the Oculus Developer Dashboard. For the rest of the settings, you can select the Environment as Quest and the Description as per your choice.
- To attach the Identity Provider to your sandbox, go to Sandboxes and select the sandbox you want to attach the Identity Provider to. Now click on Identity Providers and select the profile you just created. Press Save and you are done!
This will take a few minutes to get it to populate, give it a few minutes and you are ready to go!
Blueprint Implementation
Now that you have set up the Oculus App and the MetaXrPlatform plugin, you can start implementing the Oculus login method in your project. Here is an example of how you can do this:
- Start the Message Pump in your game instance (suggested). This is very important as this starts the delegates to be fired when the proof is generated. If you are not getting any response, this might be the reason.
- Before calling the login method, you need to check if the user is already logged in. You can do this by calling the
GetLoggedInUserId
method. If the user is logged into Oculus, the method will return the user's ID. If the user is not logged in, the method will return 0.
- Now it's time to login the user into EOS if the user is ready with the Oculus login.
Cannot view the code? Click here (opens in a new tab)
That is it! You have successfully implemented the Oculus login method in your Unreal Engine project. Now you can authenticate your users using their Oculus account.
Important Notes and Tips
- The login will only work when the build is uploaded through the Oculus Store, even if it's Dev or Alpha Stage. The login will not work if you are deploying it on your device directly.