question

smkays92@gmail.com avatar image
smkays92@gmail.com asked

Trying to use server models

Hi, i'm new in using PlayFab, i'm having problem using the server models. Ive seen the tutorial about the Update using the server model, but when i try to use inside my code, it seems like i dont have the server models inside, only got the client model. I try to get the latest asset playfab, but still got the same things, server models not exist. Its it got a specific method to call the server models?

public void UpdateUserReadOnlyData()
{
var updateRequest = new ServerModels.UpdateUserDataRequest()
{
PlayFabId = "user PlayFabId here - obtained from any successul LoginResult",
Data = new Dictionary()
{
{"Father", "Fred"},
{"Mother", "Alice"},
{"Sister", "Lucy"},
{"Brother", "Doug"}
},
Permission = PlayFab.ServerModels.UserDataPermission.Public
};

PlayFabServerAPI.UpdateUserReadOnlyData(updateRequest,
(result) => {
Debug.Log("Set read-only user data successful");
}, (error) => {
Debug.Log("Got error updating read-only user data:");
Debug.Log(error.ErrorMessage);
});
}
10 |1200

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

brendan avatar image
brendan answered

Because the Server API set (and your Secret Key) should never ship as part of your title, it is not in the primary Client SDK asset package in our Unity repo. You can find the assets you need to build a project using the Server API set in both PlayFabServerSample and PlayFabCombinedTestingSample in our Unity SDK.

10 |1200

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

smkays92@gmail.com avatar image
smkays92@gmail.com answered

Is it possible to put server models and client models in the same project?

10 |1200

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

brendan avatar image
brendan answered

Yes, the PlayFabCombinedTestingSample in our Unity SDK has the Client and Server models combined into one project.

10 |1200

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

smkays92@gmail.com avatar image
smkays92@gmail.com answered

I got it already, but seems like there is no more AuthKey inside, because previously I used AuthKey in most of my code to authenticate user login key

 

PlayFabClientAPI.AuthKey
10 |1200

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

brendan avatar image
brendan answered

Sorry, could you clarify the issue you're seeing? The PlayFabClientAPI.cs is identical between PlayFabClientSample and PlayFabCombinedTestingSample, and both make use of _authKey to track on the Session Ticket and make use of it.

There is a CallRequestContainer which has a member named AuthKey, but it is also replicated between the different project versions.

As a test, could you try removing all the PlayFab components from your project, and add the appropriate Assets folder from a clean download of the latest SDK?

10 |1200

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

smkays92@gmail.com avatar image
smkays92@gmail.com answered

My issue is, previously i do most checking at the initial of the function using the Authkey like below, but after i change and add the new server clients models, seems like i cannot use anymore the Authkey like previously and the Authkey not exist in ClientAPI anymore, so is there any specific method to call the Authkey as previously i used.

void Start()
{
if(PlayFabClientAPI.AuthKey!=null)
{
// Do some playfab api and start call my function
}
}

I try already the Container that u suggest, but it is different from the previous Authkey is it? or am I wrong, because previously I'm not need to replicated the Key, and just directly used.

 CallRequestContainer KeyKey = new CallRequestContainer();

 **Sorry because I'm really new to the PlayFab 

10 |1200

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

brendan avatar image
brendan answered

That was a change made to the Unity SDK, yes. The Session Ticket was moved to be private (_authKey) in order to prevent a rogue plugin from being able to access it as easily - it's a security issue, basically.

To check if the player has a valid Session Ticket, you can use the PlayFabClientAPI.IsClientLoggedIn() call.

10 |1200

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

smkays92@gmail.com avatar image
smkays92@gmail.com answered

Yeayyyy, this is what I'm looking for, thanks a lot for your help...

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.