question

Omar El-Sayed avatar image
Omar El-Sayed asked

Error: "/CloudScript/ExecuteFunction: NotAuthorized"

I have a game that I launched on Test Flight and Google Play Beta Release for 3 months now. The game is using Cloud Scripts in some functions related to Shop and Edit Profile, everything was working fine but suddenly anything that uses the cloud scripts stopped working WITHOUT any interfering in the code from the developers. It only outputs this error: " /CloudScript/ExecuteFunction: NotAuthorized"

Here is a sample from our code that produces this error

  private static void ExecuteFunction(object body, string functionName,
             Action<ExecuteFunctionResult> resultCallBack, Action<PlayFabError> errorCallBack,
             bool generatePlayStreamEvent = true)
         {
             PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest
             {
                 FunctionName = functionName,
                 FunctionParameter = body,
                 GeneratePlayStreamEvent = generatePlayStreamEvent
             }, Success, Failure);
    
             void Success(ExecuteFunctionResult response)
             {
                 Debug.Log($"Func {functionName} Success, Result: {response.FunctionResult} -- Execution Time: {response.ExecutionTimeMilliseconds}");
                 resultCallBack?.Invoke(response);
             }
                
             void Failure(PlayFabError error)
             {
                 Debug.LogError(error.GenerateErrorReport());
                 errorCallBack?.Invoke(error);
             }
         }
CloudScriptAuthentication
15 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.

Xiao Zha avatar image Xiao Zha commented ·

You can call the Execute Function API with postman. If the API cannot work, please provide the API response to us.

1 Like 1 ·
Omar El-Sayed avatar image Omar El-Sayed Xiao Zha commented ·

I tried it and it gave me a 500 Internal Server Error Response

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha Omar El-Sayed commented ·

While you have tested the Azure Function in Postman directly using the URL, could you please test the Execute Function API again using Postman and provide us with the API response?

1 Like 1 ·
Show more comments
Show more comments
Xiao Zha avatar image
Xiao Zha answered

You can navigate to [Title Settings] -> [API Features] and delete an entity policy in [ENTITY GLOBAL TITLE POLICY]. Please let us know if it fixes the issue. Here is the policy you should delete:

   {
     "Action": "*",
     "Effect": "Deny",
     "Resource": "pfrn:data--*!*/UpdateAvatarUrl",
     "Principal": "*",
     "Comment": null,
     "Condition": null
   }
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.

Omar El-Sayed avatar image Omar El-Sayed commented ·

IT WORKED!! Thank you! Can you please explain how removing this policy fixed our issue? We added this policy at the beginning of our development and everything was working fine, so what changed? And also how can we prevent anything similar from happening?

0 Likes 0 ·
Omar El-Sayed avatar image Omar El-Sayed Omar El-Sayed commented ·

Any updates on my question?

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha Omar El-Sayed commented ·

Since [ENTITY GLOBAL TITLE POLICY] controls the entity access of the Entity Profile (like Object,file,profile...), which is different from the API policy. If you want to disable the UpdateAvatarUrl API on client, you can refer to API Access Policy to have more information on disabling API access.

0 Likes 0 ·
syedyousuff8050 avatar image
syedyousuff8050 Suspended answered

Heading

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.