question

Greg Bradburn avatar image
Greg Bradburn asked

PlayFabClientAPI.GetTitleData: "You must be logged in to call this method"

This is probably a dumb question but I never let that stop me :)

I'm developing a multiplayer game in Unity. The game server will ultimately be on a Linux host but for debugging I'm using Clones Manager and just running it in a copy of the editor locally (i.e. localhost).

When the client starts up it will attempt to connect to the server. I wanted to leverage PlayFab's title data to store the server address so I can change it dynamically even after the WebGL client is deployed.

So I created a PlayFabDataSO Scriptable object and gave it an Initialize() method which will call PlayFabClientAPI.GetTitleData() to get the server address. My NetworkManager class uses this in its Start() method when it tries to start the client.

    public override void Start()
    {
        base.Start();


#if !UNITY_SERVER
        if (AutoStartClientBuild)
        {
            // todo add error handling for getting server address from PlayFab
            _playFabData.Initialize();
            networkAddress = _playFabData.DutchBlitzServerAddress;
            Debug.Log($"MidniteOilSoftwareNetworkManager.Start() - Starting client using network address: '{networkAddress}'");
            StartClient();
        }
#endif
    }

The issue I'm having is that the GetTitleData() calls is failing with the "You must be logged in to call this method".

I'm a little confused because my LoginManager is able to register new users and sign then in using PlayFabClientAPI.RegisterPlayFabUser() and PlayFabClientAPI.LoginWithEmailAddress().

This is where I'm getting into dumb question territory. So far I've only been working within the editor and I'm using the editor extensions to log into PreFab.

How do I go about connecting my app to PreFab when it's deployed. I assume, based on this error I need to call one of the PreFabClientAPI's login methods. How do I this without putting my credentials/secret key out there?

In addition to hosting a WebGL client I plan to publish iOS/Android and desktop clients for this game as well.

Can someone point me to a FAQ or tutorial on how I can secure my credentials and connect my app to PreFab from out in the wild?

Thanks and again I apologize if this is dumb but I'm a newbie when it comes to PreFab.

Title DataAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Rick Chen avatar image
Rick Chen answered

The PlayFab Client APIs do not require the secret key but the session ticket returned from the login APIs. Yes, in order to get the title data from client, the client must login first with one of the login APIs. For PlayFab Unity tutorial, you could refer to this document: Quickstart: PlayFab Client library for C# in Unity. You could call the GetTitleData API after the Login API call is successful.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.