cancel
Showing results for 
Search instead for 
Did you mean: 

Oculus ID return 0 and Username is empty

MariosZa
Honored Guest

Hello,

We require to get the Display name and Username for unique identification of our devices as they are logged in with specific Oculus account. I have setup an account on Oculus developer dashboard as required as well as doing all the certifications and requirements > data use checkup. 

The code in the Game Manager class is as follows 

 public bool InitOculus()
    {
        try
        {
            Core.Initialize(123****132);
            Users.GetLoggedInUser().OnComplete(LoggedInUser);
        }
        catch (UnityException e)
        {
            Debug.LogException(e);
            UnityEngine.Application.Quit();
        }
        return true;
    }
 
    void LoggedInUser(Message msg)
    {
        string name = "";
        string username = "";
        if (msg.IsError)
        {
            Debug.LogError("Failed to retrieve Oculus user.");
        }
        else
        {
            User user = msg.GetUser();
            ulong userId = user.ID;
            Debug.Log("USER ID IS " + userId);
            //ImageURL = user.ImageURL;
            username = user.OculusID;
            Users.Get(userId).OnComplete(message =>
            {
                if (!message.IsError)
                {
                   
                    name = message.Data.DisplayName;
                }
                else
                {
                    var e = message.GetError();
                    Debug.LogError($"Error loading display name: {e.Message}.");
                }
            });
        }
        Debug.Log("Display Name " + name + " and the username is " + username);
    }
 
I am posting here because there are some other posts regarding this issue but they are either too old to be valid or unanswered. 
 
Thank you in advance.
0 REPLIES 0