Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by danielgonzalez · Jul 22, 2020 at 07:53 PM · entitiesPush Notifications

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!

setprofilelanguage.jpg (97.0 kB)
Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Jul 24, 2020 at 06:54 AM

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.

Comment
danielgonzalez

People who like this

1 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image danielgonzalez · Jul 27, 2020 at 09:55 AM 0
Share

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.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Some push notifications failing to send 1 Answer

    Unity Android Push Notification Icon White T.T 1 Answer

    Error (Invalid Parameter: Name Reason) upon transferring push notification keys from dev to live project 1 Answer

    Is it possible to player's history events values from cloud script? 1 Answer

    Saving single player game date in Entity files? 2 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges