Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Taivas's avatar
Taivas
Protege
3 years ago

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);
}
}
}