Photon Oculus 인증

어플리케이션 설정

인증 공급자로 Oculus을 추가하는 것은 쉬우며Photon 어플리케이션의 관리화면에서 몇 초만에 수행할 수 있습니다. 어플리케이션의 "관리" 페이지로 이동하여 "인증" 섹션까지 아래로 스크롤합니다. Oculus에 대해 새로운 인증 공급자를 추가하거나 기존 것을 편집한다면, 다음을 필수적으로 설정해야 합니다:

  • appid: Oculus 앱의 ID.
  • appsecret: Oculus 앱의 비밀키.

클라이언트 코드

Oculus는 Oculus ID와 클라이언트가 제공한 난스(nonce)를 기준으로 사용자를 확인합니다. 암호학에서 난스는 한번만 사용할 수 있는 임의 번호입니다. 여기에서 자세히 알아보세요.

자격증명 취득

클라이언트는 Oculus에 로그인한 다음 난스를 생성해야 합니다. 이 난스는 클라이언트가 유효한 Oculus 사용자라고 증명합니다. Oculus SDK는 [해당 웹사이트]에서 받을 수 있습니다.

Unity 명령

유니티용 Oculus Platform SDK를 다운로드하고 프로젝트로 임포트합니다. 편집기의 메뉴 모음에서 "OculusPlatform" -> "EditSettings" 으로 이동하여 Oculus AppId를 입력합니다. 다음 코드를 사용하여 로그인한 사용자의 Oculus ID를 가져오고 난스를 생성합니다.

C#

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

public class OculusAuth : MonoBehaviour
{
    private string oculusId;

    private void Awake()
    {
        Core.Initialize();
    }

    private void Start()
    {
        GetLoggedInUser();
    }
    
    private void GetLoggedInUser()
    {
        Users.GetLoggedInUser().OnComplete(OnLoggedInUserCallback);
    }

    private void OnLoggedInUserCallback(Message<User> msg)
    {
        if (msg.IsError)
        {
            Debug.LogErrorFormat("Oculus: Error getting logged in user. Error Message: {0}",
                msg.GetError().Message);
        }
        else
        {
            oculusId = msg.Data.ID.ToString(); // do not use msg.Data.OculusID;
            GetUserProof();
        }
    }

    private void GetUserProof()
    {
        Users.GetUserProof().OnComplete(OnUserProofCallback);
    }

    private void OnUserProofCallback(Message<UserProof> msg)
    {
        if (msg.IsError)
        {
            Debug.LogErrorFormat("Oculus: Error getting user proof. Error Message: {0}",
                msg.GetError().Message);
        }
        else
        {
            string oculusNonce = msg.Data.Value;
            // Photon Authentication can be done here
        }
    }
}

인증

클라이언트는 "userid" 와 "nonce" 각각에 대해 쿼리 스트링 매개 변수로 Oculus ID와 생성된 난스를 보내야 합니다.

C#

loadBalancingClient.AuthValues = new AuthenticationValues();
loadBalancingClient.AuthValues.AuthType = CustomAuthenticationType.Oculus;
loadBalancingClient.AuthValues.AddAuthParameter("userid", oculusId);
loadBalancingClient.AuthValues.AddAuthParameter("nonce", oculusNonce);
// do not set loadBalancingClient.AuthValues.Token or authentication will fail
// connect
Back to top