Search Unity

How to properly handle Oculus entitlement check?

Discussion in 'VR' started by JoeStrout, Nov 7, 2018.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    My Oculus Go app has failed test VRC.Mobile.Security.1 twice now, even though I thought I'd fixed it...

    Code (CSharp):
    1.         // Start up the Platform SDK.  We don't specify the App ID here,
    2.         // so it'll use (without complaint) the one set in the scriptable
    3.         // object accessed via the Oculus Platform menu.
    4.         Core.AsyncInitialize();
    5.        
    6.         // Check entitlements (required)
    7.         Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
    8. ...
    9.     void EntitlementCallback(Message msg) {
    10.         if (msg.IsError) {
    11.             Debug.LogError("Oculus Platform entitlement error: " + msg.GetError());
    12.             UnityEngine.Application.Quit();
    13.         } else {
    14.             Debug.Log("Oculus Platform entitlement success! " + msg);
    15.  
    I'm running the above code on startup. And when I test it, I see "Oculus Platform entitlement success!" in the logs.

    Yet Oculus still claims "The user is able to run the app while signed out of Oculus Home. It appears that your app does not support entitlement checks to prevent unauthorized use of your content."

    Any idea what I'm doing wrong here? Or for that matter: how exactly can I test this myself? The docs say "log in to Oculus Home with a user who doesn't have an entitlement to the app," but I'm pretty sure Oculus Home is a Rift thing, not an Oculus Go thing.

    Any ideas?
     
  2. IMUUFR

    IMUUFR

    Joined:
    Jan 31, 2019
    Posts:
    3
    Below is my code and my code has failed. Did you found answer for this?
    //public GameObject ErrorMsg;
    //public bool quitting;

    //void Start()
    //{
    // Core.AsyncInitialize("2213584798662257");
    //}

    //void Update()
    //{
    // CheckApplicationEntitlement();
    //}

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

    //void callbackMethod(Message msg)
    //{
    // if (!msg.IsError)
    // {
    // Debug.Log("passed");
    // }
    // else
    // {
    // Debug.Log("not passed");
    // if (!quitting)
    // {
    // StartCoroutine(quitApp());
    // quitting = true;
    // }
    // }
    //}

    //IEnumerator quitApp()
    //{
    // Instantiate(ErrorMsg);
    // yield return new WaitForSeconds(5);
    // UnityEngine.Application.Quit();
    // Debug.Log("hasQuit");
    //}

    void start(){
    Core.AsyncInitialize("2213584798662257");
    Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(callbackMethod);
    }

    void callbackMethod(Message msg) {
    if (!msg.IsError) {
    Debug.Log("Passed");
    }
    else
    {
    Debug.Log("Not Passed");
    UnityEngine.Application.Quit();
    }
    }
     
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    In my case, Oculus Testing apparently just had a bad day. I re-submitted with the same code (which I'm now using on two different games in the store), and it was accepted.

    Your code is difficult to read because you didn't put it in code tags. But it seems OK to me.
     
  4. IMUUFR

    IMUUFR

    Joined:
    Jan 31, 2019
    Posts:
    3
    Ok thankyou
     
  5. asdflzh

    asdflzh

    Joined:
    Jan 14, 2020
    Posts:
    2
    Have you solved the problem?
    I logged in to my apk on quest2 but prompted me user does not have app in library
    The test account also matches

    //Below is my code and my code has failed

    void Start()
    {
    Debug.Log("[unity] I am ======>>> start now.");

    // First thing we should do is perform an entitlement check to make sure
    // we successfully connected to the Oculus Platform Service.
    Entitlements.IsUserEntitledToApplication().OnComplete(IsEntitledCallback);
    }

    void IsEntitledCallback(Message msg)
    {
    Debug.Log("[unity] I am ======>>> entitle callback " + msg.GetString());
    if (msg.IsError)
    {
    TerminateWithError(msg);
    return;
    }

    // Next get the identity of the user that launched the Application.
    Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
    Users.GetAccessToken().OnComplete(GetAccessTokenCallback);

    }