question

viktor-1 avatar image
viktor-1 asked

GetStorage based on Master Player Id

We have a list of master player ids and now we ran into the requirement where we need to access the title related objects for these players.


I tried to do this by using an entity key with "master_player_account" which looks something like this:

 PlayFabDataAPI.GetObjects(new GetObjectsRequest
            {
                Entity = new EntityKey
                {
                    Id = playerId,
                    Type = "master_player_account"
                },
                EscapeObject = true
            }, OnSuccess, OnError);

This leads to a not authorized error:

Which I tried to solve by modifying the Entity Global Title Policy by adding this:

{
    "Action": "*",
    "Effect": "Allow",
    "Resource": "pfrn:data--*!*/Object/GetObjects*",
    "Principal": "*",
    "Comment": "Everyone can edit storage",
    "Condition": {
      "CallingEntityType": "master_player_account"
      }    
  }

I was troubleshooting here because I had a hard time finding a proper documentation for this - but the authorization still failed.

An alternative solution that would also work for would be to retrieve the title player ids with the master player id and then using these to access the storage. But in case this is possible I wasn't able to find how.

Thanks for any advice in advance!

unity3dCharacter Data
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

·
Citrus Yan avatar image
Citrus Yan answered

The default Entity Policy should meet your requirements already. Which Entity Token did you use for the PlayFabDataAPI.GetObjects call?. Entity Token can be retrieved using GetEntityToken or Login Calls. Login calls will return the token of the player's title_player_account entity, which can also be used to retrieve the objects in their master_player_account entity by default.

2 comments
10 |1200

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

viktor-1 avatar image viktor-1 commented ·

The only action I perform to get the Entity Key is this:

Entity = new EntityKey {                    

	Id = playerId,    
        Type = "master_player_account"

}

Do you mean with Login Calls that I should login for every user who's objects I'm trying to access? I want to iterate over a multiple hundreds of master player id - so this seems quite the overhead.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan viktor-1 commented ·

->Do you mean with Login Calls that I should login for every user who's objects I'm trying to access?

In that case, yes. And, you can also use the title-level Entity Token by calling GetEntityToken using title SecretKey to access all the users' objects. However, this should be done on the server-side because exposing it to the client-side may have security issues.

0 Likes 0 ·

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.