question

Konstantin Milev avatar image
Konstantin Milev asked

Question: Reading data from player account

Hello,

I'm having an issue with CloudScript/Unity SDK

Basically I'm making a CloudScript function that's supposed to get data from player's account - in this case, a token (ex: 8jhxv9qk4isk1ckdrt0) which was previously generated and saved to the account. Here I'm supplying a PlayfabID to that account to get the saved token:

handlers.getRandomToken = function (args) {
    var playerData = server.GetUserReadOnlyData({"PlayFabId" : args.inputValue, "Data" : ["Token"]}); 
    var token = {};
    if(playerData.Data.hasOwnProperty("Token")) { token = playerData.Data["Token"]; }
    log.info(token);
    return { messageValue: token};
};

This token gets sent back to the client that called the method (from a callback), but the problem is that the "format" of token that is returned is not correct (contains other stuff): {"Value":"8jhxv9qk4isk1ckdrt0","LastUpdated":"2019-10-04T20:11:33.268Z","Permission":"Public"}
This is where I receive the result (token):

private void OnGetUserToken(ExecuteCloudScriptResult result)
    {
        JsonObject jsonResult = (JsonObject)result.FunctionResult;
        jsonResult.TryGetValue("messageValue", out object messageValue);
        UserToken = (string)messageValue;
        Debug.Log((string)messageValue);
        Debug.Log("OnGetUserToken token value set: " + (string)messageValue);
    }
I need the thing in "Value" but I don't know how to get it... Is there anything to do with serialization?

I'd appreciate any help!
Thanks in advance!
unity3dCloudScriptdata
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

·
Konstantin Milev avatar image
Konstantin Milev answered

I managed to fix the issue by using PlayFab.ISerializerPlugin which wasn't mentioned anywhere in the docs, I managed to find it by looking at other questions in this forum

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.