question

xigmasuji avatar image
xigmasuji asked

Cannot use the CustomFunction API to call a CloudScript(Function), returns "This API method does not allow anonymous callers"

I am using an API

https://{ {TitleId}}.playfabapi.com/cloudscript/ExecuteFunction

to execute a CloudScript(Function) from Unity to Playfab, this playfab function is connected to an URL of an AzureFunction(has anonymous access). On Paper this should work, but when I do through PlayFab SDK using the

PlayFabCloudScriptAPI.ExecuteFunction

it works, otherwise, this does not work, I would like to know why for my own edification.

And yes I use an anonymous login to authenticate the session API and that too with a REST API

https://{ {TitleId}}.playfabapi.com/client/LoginWithCustomID

apisunity3dsdksCloudScript
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

·
Gosen Gao avatar image
Gosen Gao answered

Server-Side Cloud Script - Execute Function - REST API (PlayFab CloudScript) | Microsoft Learn requires an Entity Token, when you use PlayFab SDK, SDK will manage the Entity Token automatically. If you want to use REST API, you need to set the X-EntityToken header manually. You can obtain the Entity Token in the response of Authentication - Login With Custom ID - REST API (PlayFab Client) | Microsoft Learn.

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

xigmasuji avatar image xigmasuji commented ·

Yea I did that and used the entity token received from the Anonymous login, that is why it tells me This API method does not allow anonymous callers.

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao xigmasuji commented ·

This error "This API method does not allow anonymous callers" means you don't set the EntityToken. The entity token obtained from anonymous login methods like Authentication - Login With Custom ID - REST API (PlayFab Client) | Microsoft Learn can be used to call Server-Side Cloud Script - Execute Function - REST API (PlayFab CloudScript) | Microsoft Learn. You can do some tests with Postman (REST) SDK - PlayFab | Microsoft Learn to get familiar with the process.

1 Like 1 ·
xigmasuji avatar image xigmasuji Gosen Gao commented ·

Thank you for the support, you are right I have replacedthe Entity Token with the Session Token, they seem to be two different things :))

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.