I'm attempting to create a matchmaking ticket for a player using Azure Functions/CloudScript.
Here's what I'm doing exactly:
First, I get an entity token as title from my secret key.
{ path: '/Authentication/GetEntityToken', options: { method: 'POST', body: '{"Entity":{"Id":"YYY","Type":"title"}}', headers: { 'Content-Type': 'application/json', 'X-SecretKey': 'XXX' } } }
Next, I call CreateMatchmakingTicket
{ path: '/Match/CreateMatchmakingTicket', options: { method: 'POST', body: '{"GiveUpAfterSeconds":10,"QueueName":"DefaultQueue","Creator":{"Entity":{"Id":"YYY","Type":"title_player_account"}}}', headers: { 'Content-Type': 'application/json', 'X-EntityToken': 'ZZZ } } }
Finally, I get this response:
{ path: '/Match/CreateMatchmakingTicket', result: { code: 403, status: 'Forbidden', error: 'MatchmakingEntityInvalid', errorCode: 2001, errorMessage: 'The entity of the caller must be one of types: title_player_account.' } }
What I can intuit from this is that it is unhappy with the fact that the X-EntityToken I am using is for a "title" and not a "title_player_account". I've attempted to acquire an EntityToken for a title_player_account using my title EntityToken and I get the following error:
{ path: '/Authentication/GetEntityToken', result: { code: 401, status: 'Unauthorized', error: 'NotAuthorized', errorCode: 1089, errorMessage: "The claim was not allowed to perform the requested action based on the entity's access policy. Policy comment: By default, all requests are denied. If you expected this request to succeed, you may be missing a policy. See the permissions APIs in PlayFab's Admin Api to add a permission." } }
Am I approaching this the right way? Should I just make matchmaking tickets directly from the game client itself? Should I not even be bothering with proxying this to the server-side?
Answer by SethDu · Nov 24, 2020 at 07:38 AM
As the error message indicates, /Match/CreateMatchmakingTicket will require a title_player_account entity token to create a ticket on AFCS, but by default the working environment holds a title-level token.
>>Should I just make matchmaking tickets directly from the game client itself?
Yes, in most scenarios, players should make matchmaking tickets directly from the clients through client API. May I ask your concerns? If you are worried about players making up the attributes in the requests on their own, you may switch the “Attribute source” in Rule settings of Queue to “Player Entity”, which will directly retrieve corresponding value from Player’s Entity Object. While Entity Object’s access policy can be modified through Global Entity Policy, and you can deny the write permission of players so that it can be completely maintained by PlayFab server.
Still, there are very specific scenarios that need to create matchmaking ticket on the server side. In that case, you may use CreateServerMatchmakingTicket instead, which is designed to be called on server side.
I realized recently that CreateServerMatchmakingTicket exists, I hadn't realized there was a server specific endpoint to call, mainly because the other isn't called CreateClientMatchmakingTicket so I didn't really even conceptualize there'd be a difference. Works now, thanks!