question

doronhn avatar image
doronhn asked

upload entities from one account to another in same title

Hey,

I am trying to get entities from one account and upload it to another.

i am using two different entity tokens, and my error is -

"The claim was not allowed to perform the requested action based on the entity's access policy."

this is my policy:

[
  {
    "Action": "*",
    "Effect": "Allow",
    "Resource": "*--*",
    "Principal": {
      "ChildOf": {
        "EntityType": "namespace",
        "EntityId": "E1C86539AD904942"
      }
    },
    "Comment": "The default allow title in namespace full access",
    "Condition": {
      "CallingEntityType": "title"
    }
  },
  {
    "Action": "*",
    "Effect": "Allow",
    "Resource": "pfrn:data--*![SELF]/Profile/*",
    "Principal": "[SELF]",
    "Comment": "The default allow profile self access",
    "Condition": null
  },
  {
    "Action": "*",
    "Effect": "Allow",
    "Resource": "pfrn:data--*![SELF]/Profile/*",
    "Principal": {
      "ChildOf": {
        "EntityType": "[SELF]"
      }
    },
    "Comment": "The default allow profile child access",
    "Condition": null
  },
  {
    "Action": "Write",
    "Effect": "Deny",
    "Resource": "pfrn:data--*!*/Profile/Statistics/*",
    "Principal": "*",
    "Comment": "Only title can edit user statistics",
    "Condition": {
      "CallingEntityType": "title_player_account"
    }
  },
  {
    "Action": "Write",
    "Effect": "Deny",
    "Resource": "pfrn:data--*!*/Profile/Statistics/*",
    "Principal": "*",
    "Comment": "Only title can edit user statistics",
    "Condition": {
      "CallingEntityType": "character"
    }
  },
  {
    "Action": "Write",
    "Effect": "Deny",
    "Resource": "pfrn:data--*!*/Profile/Statistics/*",
    "Principal": "*",
    "Comment": "Only title can edit user statistics",
    "Condition": {
      "CallingEntityType": "master_player_account"
    }
  },
  {
    "Action": "Write",
    "Effect": "Deny",
    "Resource": "pfrn:data--group!*/Profile/Statistics/*",
    "Principal": {
      "MemberOf": {
        "RoleId": "*"
      }
    },
    "Comment": "Only title can edit group statistics",
    "Condition": null
  }
]

not sure what i need to edit here and why, this is my code:

var request = new GetFilesRequest { Entity = oldEntityToken };
        PlayFabDataAPI.GetFiles(request, (OnGetFileMeta) =>
        {
            try
            {
                PlayFabHttp.SimpleGetCall(OnGetFileMeta.Metadata[PLAYER_ENTITIES_KEY].DownloadUrl,
                    (OnGetFileFinished) =>
                    {
                        UploadEntities(OnGetFileFinished, newEntityToken);
                    }, (error) =>
                    {
                        Debug.LogError(string.Format("GetPlayerEntitesByEntityTokenAndUploadToNewEntityToken + {0}", error));
                    });
            }
            catch (Exception)
            {
                Debug.LogError("GetPlayerEntitesByEntityTokenAndUploadToNewEntityToken - GetOldAccountData - faild");
            }
        }, (OnInitFailed) =>
        {
            Debug.LogError(string.Format("GetPlayerEntitesByEntityTokenAndUploadToNewEntityToken - OnInitFailed + {0}", OnInitFailed.ErrorDetails));
        });

Upload Entities:

  public static void UploadEntities(byte[] payload, PlayFab.DataModels.EntityKey EntityToken)
    {
        try
        {
            InitiateFileUploadsRequest initiateFileUploadsRequest = new InitiateFileUploadsRequest()
            {
                Entity = EntityToken,
                FileNames = new List<string>() { PLAYER_ENTITIES_KEY }
            };


            PlayFabDataAPI.InitiateFileUploads(initiateFileUploadsRequest, (response) =>
            {
                PlayFabHttp.SimplePutCall(response.UploadDetails[0].UploadUrl, payload, (byteArray) =>
                {
                    FinalizeFileUploadsRequest finalizeFileUploadsRequest = new FinalizeFileUploadsRequest
                    {
                        Entity = EntityToken,
                        FileNames = new List<string>() { PLAYER_ENTITIES_KEY }
                    };


                    PlayFabDataAPI.FinalizeFileUploads(finalizeFileUploadsRequest, (OnUploadSuccess) =>
                    {
                        isMergeEntitesDone = true;
                    }, (OnSharedFailure) =>
                    {
                        Debug.Log(OnSharedFailure);
                    });
                },
                    (OnSharedFailure) =>
                    {
                        Debug.Log(OnSharedFailure);
                    });
            }, (OnInitFailed)=> 
            {
                Debug.LogError(OnInitFailed);
            });
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.InnerException);
        }
    }

What i am trying to do?

i am trying to merge to accounts into one.

apisAccount Managemententitiesdata
1 comment
10 |1200

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

Seth Du avatar image Seth Du ♦ commented ·

I believe there is misunderstanding on Entity Key and Entity Token. Entity Key is the ID for an entity(title player account in your scenario). Entity Token is the access token that generated after successfully login for players to access entity API calls.

I need to know more details about your scenario. May I ask where will you implement this feature? If it is an external server, you may keep the Policy unchanged and use title-level entity token to modify files for both players. If you want to grant the update permission for all players so that players can update other players' file on their own in clients, it will need some changes on the policy.

0 Likes 0 ·

0 Answers

·

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.