Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Can I get my (currently logged in) Oculus ID when I am logged into a different account

viewportviewport Posts: 80
Hiro Protagonist
edited June 2018 in Platform SDK Development
I am able to retrieve my Oculus ID while logged into the Oculus account associated with the App on the Oculus Dashboard.

The app has not been released.

While logged into another account on Oculus, my GetLoggedInUserCallback returns an error.

The second account is added as a tester and downloaded the app through the Oculus Store on a Windows PC.

Below is the code I'm running:

public class OculusInitilisation : MonoBehaviour
{
    public bool useTestID;

    public static ulong oID = 0;

    public OvrAvatar myAvatar;

    private void Awake()
    {
        if(myAvatar == null)
        {
            myAvatar = GetComponent<OvrAvatar>();
        }
        if(oID == 0)
        {
            Oculus.Platform.Core.Initialize();
            Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
            Oculus.Platform.Request.RunCallbacks();
        }
        if (useTestID)
        {
            myAvatar.oculusUserID = "10150022857785745";
        }
        else
        {
            myAvatar.oculusUserID = oID.ToString();
        }
    }

    private void GetLoggedInUserCallback(Message<User> message)
    {
        if(!message.IsError)
        {
            oID = message.Data.ID;
        }
        else
        {
            Debug.Log("FAILED TO GET ID");
        }
    }
}

The Debug.Log("FAILED TO GET ID"); is what runs.

We are building this in Unity 2017.4.2f2 using:
- OVR PlatformSDK v1.24
- OVR Utilities v1.26
- OVR Avatars v1.26

How can I get my ID from another account?
Will this only happen during development and not after release?

EDIT:  I've added an entitlement check to the start of the app after reading that it was necessary to use the Platform SDK. The check fails while on an account that I've added to the to the beta testers on the my Oculus Dashboard. The app was downloaded through the Oculus Store on Windows. Can an entitlement check be succeeded before release on a testing account.

I've added the build to the RC channel; entitlement check still fails.

Here is my code for my entitlement check, which also attempts to grab the Oculus ID:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Oculus.Platform;
using Oculus.Avatar;
using Oculus.Platform.Models;

public class EntitlementCheck : MonoBehaviour {

    public TextMesh myText;

    public GameObject testAvatar;
    
    void Start()
    {
        Oculus.Platform.Core.Initialize();
    }

    void Update()
    {
        CheckApplicationEntitlement();
    }

    public void CheckApplicationEntitlement()
    {
        Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(callbackMethod);
    }

    void callbackMethod(Message msg)
    {
        if (!msg.IsError)
        {
            SetText("Entitlement Succeeded");
            Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
            Oculus.Platform.Request.RunCallbacks();
            testAvatar.SetActive(true);
        }
        else
        {
            SetText("Entitlement failed");
        }
    }

    void SetText(string _text)
    {
        myText.text = _text;
    }

    private void GetLoggedInUserCallback(Message<User> message)
    {
        if (!message.IsError)
        {
            Debug.Log("Succeeded loading ID");
            testAvatar.GetComponent<OvrAvatar>().oculusUserID = message.Data.ID.ToString();
            testAvatar.SetActive(true);
        }
        else
        {
            Debug.Log("FAILED TO LOAD AVATAR");
        }
    }
}


EDIT 2: I've added the App id to the initialisation and the app is able to work on other accounts on windows but when I run the test on an Oculus GO, after downloading through the Release channel on the store, The Entitlement check fails and I'm unable to load the any Avatar.

Best Answer

  • viewportviewport Posts: 80
    Hiro Protagonist
    Accepted Answer
    I had App Id's mixed up between apps. Once I was using the app in the RC channel with the correct IDs, it worked.
Sign In or Register to comment.