question

kennyroy avatar image
kennyroy asked

ListMembership doesn't work in CloudScript -policy issue?

I don't want to throw out any red herrings but I am unable to get any results back from a Listmembership call through cloud script. I feel the docs are extremely lacking on some of the entity calls and especially in the area of policy. I've become quite frustrated by the fact that when I am stuck there is no quick reference guide with examples. For example, the doc on Listmembership doesn't even mention it takes a title_player_account, little things like that make someone new to the platform waste lots of time.

So now that I'm at the point of making that call through cloudscript the response is empty no matter how many groups the entity is a member of. So I come back to the forums and see that other people have issues with policy and so I'm sure I don't need to start describing here again how poor the documentation is on policy.

Can I get some specific help with my issue here?

Title A2460

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

kennyroy avatar image kennyroy commented ·

So I've been at this all day and I'm still nowhere. I've become extremely frustrated because the docs only describe updating and getting policy, but each resource does not have it's resource name or formatting of that resource string listed anywhere. So it's literally guesswork. Not only that, the format is different in the docs to what it comes out as in the GameManager (and what's advised here).

Docs: "pfrn:api--/API-GROUP/API-CALL"

Forums and GameManager: "pfrn:group--group!*/Roles/*"

...????

What I have been able to confirm:

  1. Unity SDK: ListMembership on a title_player_account will return the groups they belong to if the calling entity is in the group as well. Returns empty list even if the passed entity is in a group, if the calling entity is not.
  2. Server / Cloudscript: Perhaps related to #1, server/cloudscript calls to ListMembership return no groups. Could be the fact the server is not a member? Seems a Policy 101 problem, but the forum help is old, and docs useless.

Unfortunately, if I don't get some help on the policy, I'm dead in the water. ListMemberships is absolutely pivotal to the function of my game, and HAS to be cloudscript, or else rampant cheating is possible.

0 Likes 0 ·

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

Hi @kennyroy,

I can see you posted a related question in this thread, I am answering that in this one.

So, in order to call ListMembership in Cloud Script, you must specify the entity to act on, this API takes one parameter: “Entity”. Hence, the proper way to call it would be:

entity.ListMembership({Entity:titlePlayerAccount});

I modified your code and tested in my title, it can return the expected results:

handlers.listGroupMembership= function (args, context){  

var titlePlayerAccount = server.GetUserAccountInfo({ PlayFabId: currentPlayerId}).UserInfo.TitleInfo.TitlePlayerAccount;

var getMemberships = entity.ListMembership({Entity: titlePlayerAccount});  

return getMemberships;

}

By the way, GetUserAccountInfo won’t be needed in the Cloud Script since you will be able to get the title_player_account entity from Login APIs such as LoginWithCustomId: EntityTokenResponse, passing it to the Cloud Script would save the need of calling GetUserAccountInfo API.

I don’t think this issue that the response from CloudScript is empty no matter how many groups the entity is a member of is related to policy. However, about your feedback about docs on policy and entity operations, I will report it to the doc team, really sorry for the inconvenience.

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.

kennyroy avatar image kennyroy commented ·

Ok thank you for taking a close look and fixing this.

I guess my confusion was that I had to actually pass the argument name ("Entity") as well as the entityKey itself.

As far as grabbing the titlePlayerAccount from the entityTokenResponse, I do not want to do that because it is technically possible for a player to spoof another player and pass in their titlePlayerAccount as their own. The game relies entirely on the player calling CloudScript that handles ALL of the checks on the ownership and membership of a group, in order to award currency.

Thanks again for taking a look.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan kennyroy commented ·

Glad it helped:)

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.