question

Daniel González avatar image
Daniel González asked

ProfileAPI SetProfileLanguage randomly returning NotAuthorized

I am using the ProfileAPI through my server to set the profile language of the "master_player_account" entity of the players after registering on my app.

Using the Java SDK, I set the DeveloperSecretKey, I call PlayFabAuthenticationAPI.GetEntityTokenAsync so PlayFabSettings.EntityToken is set.

I checked that the token expires in 24h.

But those are the results I get when calling PlayFabProfilesAPI.SetProfileLanguageAsync (with

ExpectedVersion parameter set to 0)

Most of the requests are failing with a NotAuthorized error.

As the entity token is expected to last for 24h I can't really understand what's going on.

Here is the description of the error:

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.

If I manually check the profile of a user that gave the error, I can see that the profile version is 1 (and the language is null)

I am not using the EntityAPI for anything else, so this is my only use case.

As I thought that the issue could be a race condition on Playfab's side, I delayed the SetProfileLanguage call 10 seconds after the user is logged in, but I still have the same random results.

I am losing most of my users' language preferences, and that's really unconvenient because I can't safely send push notifications and expect users to get them in their preferred language.

Any advice would be appreciated!

Push Notificationsentities
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

·
Sarah Zhang avatar image
Sarah Zhang answered

The title entity should have access to set profile language for any title player if you keep the title entity access policy as default. If you get this error “The claim was not allowed to perform the requested action based on the entity's access policy. ...See the permissions APIs in PlayFab's Admin API to add permission.” Generally, it means you use a title player’s entity token to access another player’s entity. So you can try to add the print method for your server application to print the entity token’s type in the log. Check if it is always the title entity token.

Besides, players can access the SetProfileLanguage to modify their own language configuration using their own entity. Setting the profile language does not involve cheating, so you can let players call this API in the clients directly.

1 comment
10 |1200

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

Daniel González avatar image Daniel González commented ·

The issue was caused because the SDK is using a static variable for storing the EntityToken (PlayfabSettings.EntityToken)

A call PlayFabAuthenticationAPI.GetEntityToken will set that static variable for other functions to use it.

The problem was that ClientAPI.LoginWith**** functions are setting this variable too. So the token changed from a title entity to a player's entity. I am using ClientAPI on the server because it was more convenient than having complex code on the clients.

The fix was to copy and modify the SDK functions I'm interested in, so they don't rely on static variables but parameters, avoiding those side effects and allowing the SDK to be used in a multithreaded environment.

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.