question

ptarabrin avatar image
ptarabrin asked

Аnonymous users indeed have restricted access to certain PlayFab APIs?

Hello PlayFab Community!

I'm developing a game using Unity and employing Azure Functions to invoke PlayFab APIs. I've encountered an issue when trying to use ExecuteInventoryOperationsToPlayer to grant items to anonymous users, receiving an "Unauthorized" error indicating that anonymous calls are not allowed.

Can you confirm if anonymous users indeed have restricted access to certain PlayFab APIs? What recommendations or best practices can you provide to circumvent these restrictions while maintaining the ease of anonymous login?

Thanks for your assistance!

Player Inventory
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

·
Neils Shi avatar image
Neils Shi answered

This issue has nothing to do with whether the player is an anonymous user. Anonymous users have the same access rights to PlayFab APIs as other non-anonymous users. The Unauthorized error “This API method does not allow anonymous callers” indicates you don’t provide the entity token/session ticket which required to call this API. In your case, calling the API ExecuteInventoryOperations in the Azure Function needs title entity token to perform authentication. In fact, no matter the method for executing a script the Title Authentication context is always provided, and it includes the Title ID and Title Entity Token used to execute the script. You can refer to https://learn.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/cloudscript-af-context#use-the-shared-title-authentication-context-model for more details. In addition, if you mean that this unauthorized error occurs when the player calls the API ExecuteFunction, since this API also requires an Entity Token (players can obtain it after successfully logging in), you may check if the EntityToken is successfully passed.

10 |1200

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

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.