question

hampusbankler avatar image
hampusbankler asked

Best practice - Steam account names

I have a bunch of players that have signed up during the alpha, where they have been registered with email and username and password.

I'm now integrating Steam. When the game is eventually released, people will be signed up with their Steam account instead. Until then, I need the email registration to be open (maybe even after launch I need them to work in parallell, if I distribute the game outside Steam, or for testing accounts).

When the Steam registration is done, the player does not get a PlayFab username. (That is not ideal, since it makes it much harder to get an overview in the Players and LeaderBoard and many other sections in PlayFab's web gui.) *see note 3 below though

So, I'm consider making a call to playfab after the Steam registration and set a Username, for instance to the users Steam account name.

1) The problem I first came to think of was how I then could enforce unique Usernames. Any good suggestion? Use a prefix maybe, like s_MySteamName or something?

2) While writing this post, I realized that even then, it wouldn't be that easy. AddUsernamePasswordRequest requires a password, and that isn't what I want to do. I saw that you talked about potentially allowing post-account-creation setting of Usernames in some other thread (April 2016), but not sure if this is even possible?

3*) Also, when writing this post, I realized after testing it that the field "Display name" is actually shown in the web gui pages in the absense of a Username. Could this be the answer to it all maybe? I.e upon account creation, make a UpdateUserTitleDisplayNameRequest request? And then change everywhere in the game where I show the player's Username to instead show the DisplayName?

Sorry for the somewhat confusing unorganized topic/rambling. I guess I just want some input if I'm approaching this from the right angle or if there's something I need to think about. :)

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 answered

Uniqueness is always a problem if the names aren't guaranteed unique by the originating service. In the case of PlayFab, Usernames must be unique across all titles sharing a Publisher ID, and Title Display Names must be unique within a single Title ID.

Now, specific to Steam, while their usernames must be unique, they can also be up to 32 characters, where PlayFab Usernames are up to 20, and Title Display Names are up to 25. We may change that in future to provide more flexibility, but for now the thing to know is that you can't guarantee uniqueness for a Steam name in either, due to this.

But before you start pulling hair out, there is an easier way which we'll be making available shortly - just use their Steam username. Currently, if you try searching on players by their Steam usernames in the Game Manager, you'll find that this works - and that their Steam name appears on the tile showing their linked Steam ID. That's because we're adding that information to the player profile in our service. We'll be providing ways to access more of that data in the near future, starting with the leaderboards in an upcoming release (pre-GDC).

11 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.

hampusbankler avatar image hampusbankler commented ·

Thanks for the input. Much appreciated. I ended up disabling the uniqueness requirement for Display Names. When the user registers/login with Steam, if the DisplayName is not already set (i.e. IsNullOrEmpty), it's immediately set to the user's Steam account name.

0 Likes 0 ·
brendan avatar image brendan ♦♦ hampusbankler commented ·

I'm not sure I follow. There is no way to disable the uniqueness requirement for Title Display Name in PlayFab. What I meant above was that the Steam username is in the player profile information, which we'll be making available soon, starting with leaderboards.

0 Likes 0 ·
robert avatar image robert brendan ♦♦ commented ·

We did the very same for our upcoming game as we also require non-unique display names. (we just use the Facebook name as display name).

Done via: Settings->API Features->Allow non-unique player display names

Granted, this already makes a few problems like trying to add friends by their name. So if there is any upcoming feature planed to allow non-unique username/displayname/or something new it would be really great to get a few infos about this before we launch so that we don't have troubles migration the data then and can prepare everything already...

0 Likes 0 ·
Show more comments
Brian Jordan avatar image Brian Jordan commented ·

Hi Brendan, is Steam username now available anywhere from within the PlayFab API? The string in the Steam username field shown within the Game Manager description would be ideal. Hoping to access it in a server-authoritative way, and avoiding duplicating it on the Display Name field would be awesome.

Alternatively, could the server map the Steam ID to a username using Steamworks.NET?

0 Likes 0 ·
brendan avatar image brendan ♦♦ Brian Jordan commented ·

Yes, you can get the Steam Username from the profile. When you retrieve the profile, set ShowLinkedAccounts to true, and it'll be the Username element of the linked account data returned. This is something we would recommend only doing in a server-side call though, so that you don't expose account info for all linked account types to the players.

0 Likes 0 ·
Denzie Gray avatar image Denzie Gray commented ·

@Brendan

Currently hitting the 20 character limit myself in 2020.
Is there an ETA on the Steam integration?

0 Likes 0 ·
brendan avatar image brendan ♦♦ Denzie Gray commented ·

Updates to features, as well as new features, aren't worked on in date-reported order, they're worked on in priority order based on impact to the community. Since there have been relatively few requests for longer usernames, this hasn't bubbled up in priority.

I'm not sure what you mean by "the Steam integration" - can you clarify? The Steam usernames are already available in the user accounts. That's specifically what I was describing in the original post. The profile elements you can get with a leaderboard can include the linked accounts - it's in the settings in your title - but we don't recommend it, as that can expose private info about the user. If you want to use that in leadearboards, you may want to query them in scripts and filter out any sensitive info before returning it to the client.

0 Likes 0 ·
Denzie Gray avatar image Denzie Gray brendan ♦♦ commented ·

@Brendan

"If you want to use that in leadearboards, you may want to query them in scripts and filter out any sensitive info before returning it to the client."

May I have a cloudscript example?

0 Likes 0 ·
Show more comments
Show more comments
wrathgor avatar image
wrathgor answered

@Brendan This code below does not work to get player steam name.

LoginWithSteamRequest request = new LoginWithSteamRequest();
        request.TitleId = PlayerDataScript.PLAYFAB_TITLE_ID;
        request.CreateAccount = true;
        request.SteamTicket = GetSteamAuthTicket();
        request.InfoRequestParameters = new GetPlayerCombinedInfoRequestParams();
       
        request.InfoRequestParameters.GetUserData = true;
        request.InfoRequestParameters.GetPlayerStatistics = true;
        request.InfoRequestParameters.GetPlayerProfile = true;
        request.InfoRequestParameters.GetUserAccountInfo = true;
        request.InfoRequestParameters.GetUserInventory = true;
        request.InfoRequestParameters.GetUserVirtualCurrency = true;
        request.InfoRequestParameters.GetTitleData = true;
        request.InfoRequestParameters.GetUserReadOnlyData = true;
        PlayFabClientAPI.LoginWithSteam(request, OnComplete, OnFailed);
OnComplete function:

Debug.Log(result.InfoResultPayload.AccountInfo.Username);
Debug.Log(result.InfoResultPayload.PlayerProfile.DisplayName);
Debug.Log(result.InfoResultPayload.PlayerProfile.LinkedAccounts[0].Username);

All of these debugs returns null string or null reference exception. Thanks.
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.

brendan avatar image brendan ♦♦ commented ·

Trying to dereference something without first checking to see if it's null is always going to be a bad idea, so I'd recommend adding some checks to that logic flow. For one thing, there won't be a Username on the account in question, as it wasn't created using any method that sets the Username (unless AddUsernamePassword was subsequently used). Can you try logging the InfoResultPayload, so see what all you're getting back?

1 Like 1 ·
wrathgor avatar image wrathgor commented ·

@Brendan Thanks for the reply, It just returns PlayFab.ClientModels.GetPlayerCombinedInfoResultPayload as debug. As you can see I can see the player's name in Playfab panel but can't get in game.

0 Likes 0 ·
brendan avatar image brendan ♦♦ wrathgor commented ·

That's the players name in Steam. That is not used for the PlayFab Username or for the Title Display Name. If you're not explicitly setting those, they will not have anything in them.

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.