Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Doronhn · Oct 23, 2020 at 10:02 AM · apisAccount Managementdataentities

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.

Comment

People who like this

0 Show 1
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Oct 26, 2020 at 01:52 AM 0
Share

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 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Waiting for results in Playfab API 2 Answers

    How to get/set entity objects in CloudScript? 1 Answer

    Encryption of Steam Ticket using RSA is invalid 1 Answer

    Can't use RequestMultiplayerServer API from Client 1 Answer

    Can we create or host events in Playfab's Clan/Guild? 2 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges