Привет всем. Есть кто-то с документацией. Как добавить человека в группу. Там нет документации нигде. Я не могу снять токен.
Привет всем. Есть кто-то с документацией. Как добавить человека в группу. Там нет документации нигде. Я не могу снять токен.
Hello everyone. There is someone with the documentation. How to add a person to a group. There is no documentation anywhere. I can not withdraw the token.
Hi @battlepolygon,
I can see you also posted the code in this thread, I believe they are related, so I am answering here.
“Only requests using a Title principal may directly add members to groups” means that the entity token you used for the AddMembers API was not a title entity token, for instance, a title_player_account entity token. You must first retrieve the title entity token using the GetEntityToken API and then pass it to the AddMember API, I made some modifications to your code:
public static void AddMemberToGroup() { PlayFabGroupsAPI.AddMembers ( new AddMembersRequest { Group = new EntityKey { Id = "group id of your title" }, Members = new List<EntityKey> { new EntityKey { Id = "title player entity of your player", Type = "title_player_account" } }, AuthenticationContext = new PlayFabAuthenticationContext() { EntityToken = " title entity token retrieved from the GetEntityToken API" } }, (result) => { Debug.Log("success"); }, (error) => { Debug.Log(error.ErrorMessage); } ); }
Once you retrieved the title entity token (it’s suggested that you do it from server side since it would expose the secret key to the client) and pass it in the AuthenticationContext property, the AddMembers API should work properly.
Moreover, you can consider moving the “add members” logic to the Cloud Script, which safer and simper. There is no need to call GetEntityToken to retrieve the title entity token first, calling entity.AddMember() should do the work.
2 People are following this question.