question

ross avatar image
ross asked

PlayFab.ClientModels.PlayerProfileModel returning null for LinkedAccounts

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.

ross avatar image ross commented ·

So I accidently used command+[ to try to format my post and it cause it to post without the body. So here is part of what I wrote :

I am using the Unity SDK v2.33.171127

I am trying to get the linked account for a player. However after retrieving a PlayerProfileModel the LinkedAccounts attribute is null.

Here is the code I used to get the player profile

var req = newGetPlayerProfileRequest
{
     PlayFabId = PlayerPrefs.GetString("playfabId")
};

PlayFabClientAPI.GetPlayerProfile(req,
(GetPlayerProfileResult obj) => {
    if (cb != null)
    {
        Debug.Log(obj.PlayerProfile.DisplayName); // this is correct
        Debug.Log(obj.PlayerProfile.LinkedAccounts); // this is Null
        cb(obj.PlayerProfile);
    }
},
(PlayFabError obj) => {
    Debug.Log("Playfab : unable to get player profile ");
    cb(null);
});

I validated the "Linked Accounts" setting for the app was checked. Can't upload a screen shot at the moment

Is there something else I should be doing to get the LinkedAccounts?

0 Likes 0 ·
ross avatar image
ross answered

Adding the profile constraints parameter to the profile request fixed the LinkAccount = null problem. However as indicated by @Brendan, this appears to not be the preferred way to test whether a user has certain linked accounts

var req = newGetPlayerProfileRequest
{
     PlayFabId = PlayerPrefs.GetString("playfabId"),

     //Added this to fix the problem
     ProfileConstraints = new PlayerProfileViewConstraints()
     {
          ShowDisplayName = true,
          ShowLinkedAccounts = true,
     }
};

PlayFabClientAPI.GetPlayerProfile(req,
(GetPlayerProfileResult obj) => {
    if (cb != null)
    {
        Debug.Log(obj.PlayerProfile.DisplayName); 
        Debug.Log(obj.PlayerProfile.LinkedAccounts);
        cb(obj.PlayerProfile);
    }
},
(PlayFabError obj) => {
    Debug.Log("Playfab : unable to get player profile ");
    cb(null);
});
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.

brendan avatar image brendan commented ·

Correct - we'll be providing a separate set of permissions for profile elements the player can see about themselves, but not be visible to others in a future update. For now, I'd recommend just checking the profile using the Server API call in a Cloud Script handler, if you need that data.

1 Like 1 ·
brendan avatar image
brendan answered

What is the Title ID you're testing, and the PlayFab ID of the user, so that we can have a look?

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.

ross avatar image ross commented ·

Is there a way to post a reply as a private response?
The title ID is 928D, There is only one player on that title 831CA62A480362A3

0 Likes 0 ·
brendan avatar image brendan ross commented ·

No, the purpose of the forums is so that everyone can share in the information on how problems were resolved, so that they can benefit from the experiences of others. We'll never ask for things you need to keep secret in the forums, like your Secret Key.

For the GetPlayerProfile call, it's working fine in my testing. In your code above, it looks like you're not setting the ProfileConstraints - can you check that you're setting to true any profile data you want to get back?

Also, just as a reminder - please bear in mind that turning on that particular profile response (linked accounts) does mean that clients will be able to query the linked account info for any player in your game, which potentially exposes PII. We highly recommend leaving that profile option turned off.

1 Like 1 ·
ross avatar image ross brendan commented ·

Yep, I added the profile constraints and was able to query the linked account

And when turning off the linked accounts in the client profile options prevents the profile from then being returned.

I understand the need to limit the PII exposure in the game. My ultimate need is to detect whether a particular user has a linked facebook account so that I can properly display a "Link to Facebook" button or an "Unlink to Facebook" option in the account area.

I suppose one alternative would be to store a "hasFacebookAccount" boolean in the user's playfab profile custom data but that seems a bit hackish.

Is there other ways to gather whether a user has a linked facebook account without exposing the PII of that account?

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.