Skip to main content
New Participant
October 15, 2021

How do i access oculus username?

I've searched everywhere and i have not been able to find a single post about how to get a string of text which contains the local player's username. Does anyone know how to do it with v33, and if so can you go into detail a bit, thankyou.

    This topic has been closed for replies.

    5 replies

    Honored Contributor
    October 15, 2021

    Getting the username of a player is part of the Oculus Platform SDK. The documentation on how to use it in Unity can be found here. The most important prerequisite is that you'll need an AppID by creating an application in the Developer Dashboard.

     

    To start using the Platform SDK, you'll first have to do an entitlement check as outlined here.

    Using either Platform.Core.Initialize(appID) or Platform.Core.AsyncInitialize(appID)

     

    Then, you'll be able to use Platform.Users.GetLoggedInUser() to retrieve a username.

     

     

    using Oculus.Platform;
    using Oculus.Platform.Models;
    using UnityEngine;
    
    public class PlatformSDKTest : MonoBehaviour {
    
      private void GetUserName() {
         Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
      }
    
      private void GetLoggedInUserCallback(Message msg) {
        if (!msg.IsError) {
          User user = msg.GetUser();
          string userName = user.OculusID;
          string displayName = user.DisplayName;
        }
      }
    }

     

     

     

    New Participant
    October 15, 2021

    Hello, and thankyou.

    This was able to give me the username and display name that i needed but i require some help on getting that name and putting it on something like a UI, i am sideloading the app onto my vr so i dont know if it is a problem with my code or if you arent able to access the user from sideloaded apps


    Thankyou

    Honored Contributor
    October 15, 2021

    Is there any specific error you're getting? I'm not sure which step you're stuck on.

    Make sure you've added the AppID in the OculusPlatformSettings file in Unity. To be safe, I'd also upload an initial build to a release channel in the Oculus Developer Dashboard.

    This blog post might also be helpful to you.

    New Participant
    October 15, 2021

    Sorry this one was my bad, there was an obvious problem that skipped over my head. It all works now and i can successfully get a player's username and id and all those details. Thankyou

    New Participant
    June 24, 2022

    Is it native Oculus Id? Can you get somehow Facebook id, considering that most of users have merged accounts or login with Facebook?