Skip to main content
Inspiring
November 4, 2023

Hello! I'm having trouble with user identification.

Authentification request sends Oculus User ID: 0 even though all permissions are valid in developer dashbpard. My code:

 

using Oculus.Platform;
using Oculus.Platform.Models;
using UnityEngine;

public class UserIdentification : MonoBehaviour
{

private void Awake()
{
Oculus.Platform.Core.AsyncInitialize("227131****73792");
}

private void OnOculusPlatformInitialized(Message<string> message)
{
if (message.IsError)
{
Debug.LogError("Oculus Platform initialization failed: " + message.GetError().Message);
}
else
{
Debug.Log("Oculus Platform initialized successfully.");
// You can now safely use Oculus Platform functions here.
}
}

private void Start()
{
// Call the method to get the user information
GetUserName();
}

private void GetUserName()
{
// Request the currently logged-in user's information
Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
}

private void GetLoggedInUserCallback(Message<User> message)
{
if (!message.IsError)
{
// Retrieve user information
User user = message.Data;
string userName = user.ID.ToString(); // Oculus User ID
string displayName = user.DisplayName;

// Display the user information
Debug.Log("Oculus User ID: " + userName);
Debug.Log("Display Name: " + displayName);
}
else
{
Debug.LogError("Error getting user information: " + message.GetError().Message);
}
}
}

1 reply

jtriveri
Honored Contributor
November 4, 2023

We’re seeing similar behavior. Can’t say for sure but I think v59 may have changed something. 

https://communityforums.atmeta.com/t5/General-Development/GetLoggedInUser-returns-Oculus-ID-0-with-v59-update/td-p/1100026