question

Paul Pacheco avatar image
Paul Pacheco asked

ListMembership empty

I am trying to implement parties.

In my server I am creating a entity group like this:

 var request = new CreateGroupRequest
 {
     Entity = new EntityKey
              {
                 Id =characterid,
                 Type = "character"
              },
     GroupName = characterid
 };
 PlayFabGroupsAPI.CreateGroup(request, resp =>
 {
    // yay this worked
 }, err =>
 {
    // some error
 });


That is working great, I can see my group created in the playfab console, and my character set as the administrator.

Now, I try to retrieve my character's membership like this:

var request = new ListMembershipRequest
{
    Entity = new EntityKey
              {
                 Id =characterid,
                 Type = "character"
              }
};

PlayFabGroupsAPI.ListMembership(request, resp =>
{
    foreach (var group in resp.Groups)
    {
        // nothing is coming here
    }
}, err =>
{
    Debug.Log("No party found " + err.GenerateErrorReport());
});

but resp.Groups is coming back empty. Is there some undocumented policy I am missing? I thought if the server is the caller he has access to everything by default no?

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

·
Seth Du avatar image
Seth Du answered

Does the second part print out any error message? The Entity Key in ListMembershipRequest should be a Group Entity Key not a Character Entity Key. Be aware that only the Administrator of the group is authorized to list members and before you call PlayFabGroupsAPI.ListMembership, make sure the Administrator's Entity Token has been configured.

Entity Token can be retrieved via GetEntityToken and if ‘API policy’ related error messages occurs, you may have to manually configure Policy of your title. Please see Introducing API Permission Policies and API Access Policy. Since there is no very detailed documentation in our website, our suggestion is keeping track of our documentation updates and trying to implement your group features via Cloud Script.

4 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.

Paul Pacheco avatar image Paul Pacheco commented ·

There is no error message. I verified that the ListMembership call succeeds by putting a breakpoint and Debug.Log message, but the list of groups is empty.

Maybe I misunderstand the documentation, I want to know all the groups that a character belongs to, which is what I understand ListMembership does: https://api.playfab.com/documentation/groups/method/ListMembership It seems to take the character entity key. If I had the group entity key already, thre would be no need for me to call the service at all.

From the documentation, it seems ListGroupMembers is the one that takes the group entity key and returns the members. I want the opposite way: I have a character and I want to know what groups he belongs to.

Notice this is in the server, not the client, users don't authenticate in the server, they only authenticate in the client and get the entity token in the client.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Paul Pacheco commented ·

Oh, sorry, I was talking about ListGroupMembers and yes, what you have mentioned is correct, I mixed them up.

However, for ListMembership, I have tried the API calls for several times, and all respond correctly.

Is there any chance that you have modified Group Policy? Please check [Groups] -> [your group] -> [Policy] tab, is there only '[]' left?

0 Likes 0 ·
Paul Pacheco avatar image Paul Pacheco Seth Du ♦ commented ·

Ok, I figured it out, I needed to add this policy:

{
   "Action": "Read",    
   "Effect": "Allow",
"Resource": "pfrn:group--group!*/Roles/*",
"Principal": {
"ChildOf": {
"EntityType": "title",
"EntityId": "1234"
}
},
"Comment": "Allow all players to read group roles",
"Condition": null
}
1 Like 1 ·
Show more comments

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.