I'm making 1 on 1 board game on web(use javascript). I use matchmaking API and complete successes. but response data has only Entity. I'd like to get an opponent profile(Display name and Avatar image URL).
How to get an opponent profile data?
I'm making 1 on 1 board game on web(use javascript). I use matchmaking API and complete successes. but response data has only Entity. I'd like to get an opponent profile(Display name and Avatar image URL).
How to get an opponent profile data?
The Id of the Entity returned from GetMatch is the title_player_account id, and I am assuming that you want to retrieve the opponent’s profile using GetPlayerProfile, which uses the PlayFabId ( the same as the master_player_account id), is that correct?
If that’s your case, so the question now is how to get the PlayFab Id (master_player_account id) from the title_player_account id. The GetProfile API can retrieve it, it’s returned in GetEntityProfileResponse -> Profile -> Lineage -> MasterPlayerAccountId, so that you can use it with GetPlayerProfile to retrieve the opponent’s profile data. However, one thing to note is, by default, a player entity cannot use GetProfile to retrieve other player’s entity profile, you have two options:
{ "Action": "Read", "Effect": "Allow", "Resource": "pfrn:data--*!*/Profile/*", "Principal": "*", "Comment": "allow title player access other's profiles ", "Condition": { "CallingEntityType": "title_player_account" } }
So that you can retrieve the opponent’s PlayFab Id directly from the client side, and proceed with GetPlayerProfile.
Thank you for your help! I resolved it by changing the GlobalPolicy!
Please also note that, by changing the policy, players can access each other's entity profiles (including entity objects, statistics, etc.). If you have some private data stored for players in entity profiles, you may need to add some additional policies to avoid that.
2 People are following this question.