Sign In Register

How can we help you today?

Start a new topic
Answered

Change Username with Device Authentication

I am registering a device with the DeviceAuthentication and then allowing the user to update their username.


The problem is the next time they open the app it creates a new player. Is there no way to change the username for a player that uses device authentication?


Best Answer

Hi,


When you perform a DeviceAuthenticationRequest the userName for that account gets stored in the following format, "gameID - DeviceOS - DeviceID". So if you change the username at this point you break the connection between the device and that account. What you should do after DeviceAuthentication is either authenticate socially with a players external account or add (in your case change) the userName and add a password to the account so the player can log back in no matter what device they are on. You can do this with a ChangeUserDetailsRequest. You should think of a DeviceAuthentication as a temporary log in before a player connects a social account or adds a password. I hope that helps.


Thanks,

Liam


Hi TnT,


When the player is opening the app after they have updated they're username what username are you using to sign them in? Could you provide a client side log of the steps you take to log the player in after they have updated they're username?


Kind regards

 - Steve

I should also mention we are using Unity. We use device authentication request to log them in. 

new GameSparks.Api.Requests.DeviceAuthenticationRequest().Send((response) => { ...


The username that is created with the initial device authentication is not user friendly so we allow them to updated it to something of their choosing. We also use the username for sending requests to other players to join a team. We can use display name but we want all display names to be unique, since username already has a unique check built in we just update the username and display name to be the same.


Below is what I see when they try to login a second time after changing their username. You can see it thinks it is a new player. 

GS: SEND:{"@class":".DeviceAuthenticationRequest","deviceId":"C76A0175-C5E9-5A19-9432-9E52A12B193F","deviceOS":"ANDROID","deviceType":"Desktop","operatingSystem":"OSXEditor","requestId":"636092756323136750_0"}
UnityEngine.Debug:Log(Object)
GameSparks.Platforms.<DebugMsg>c__AnonStorey22:<>m__0() (at Assets/GameSparks/Platforms/PlatformBase.cs:150)
GameSparks.Platforms.PlatformBase:Update() (at Assets/GameSparks/Platforms/PlatformBase.cs:67)

GS: RECV:{"@class":".AuthenticationResponse","authToken":"3422bc29-499f-4a21-8e7e-c461d16f5ee7","newPlayer":true,"requestId":"636092756323136750_0","userId":"57d6d44092c95a70de9f795f"}
UnityEngine.Debug:Log(Object)
GameSparks.Platforms.<DebugMsg>c__AnonStorey22:<>m__0() (at Assets/GameSparks/Platforms/PlatformBase.cs:150)
GameSparks.Platforms.PlatformBase:Update() (at Assets/GameSparks/Platforms/PlatformBase.cs:67)

 

Answer

Hi,


When you perform a DeviceAuthenticationRequest the userName for that account gets stored in the following format, "gameID - DeviceOS - DeviceID". So if you change the username at this point you break the connection between the device and that account. What you should do after DeviceAuthentication is either authenticate socially with a players external account or add (in your case change) the userName and add a password to the account so the player can log back in no matter what device they are on. You can do this with a ChangeUserDetailsRequest. You should think of a DeviceAuthentication as a temporary log in before a player connects a social account or adds a password. I hope that helps.


Thanks,

Liam

We are using the device authentication request as a temporary request. We allow the user to link their facebook or google account at a later time. What we don't want to do however is force a player to link an account if they don't want to so we allow them to play the game only using device authentication and if they like it and want to save their progress then they can link an account. 


So what I am hearing is no, you cannot change the username with device authentication. We can however change the username with any other type of authentication. We will have to write our own code then to just use display names throughout the app and check for duplicate display names when creating a new player.


If we could add a feature request it would be to store the device authentication connection information in a different place than the username field so people can update the username to whatever they want.


2 people like this
Login to post a comment