Sign In Register

How can we help you today?

Start a new topic
Answered

Error handling && Cant use ChangeUserDetailsRequest

Hello 2 question:


I want to make statement in my code regarding for example response of registration if the username is already taken i have this response

{
 "@class": ".RegistrationResponse",
 "error": {
  "USERNAME": "TAKEN"
 },
 "newPlayer": false,
 "scriptData": null
}


how can i Make an if statement in unity like that:


if (requestResponse.HasErrors)
{
//It didn't work
if ( requestResponse.Errors.getString("TAKEN")
Debug.Log ("already taken");
}


Then my second problem is using DeviceAuthenticationRequest and if later i want to use ChangeUserDetailsRequest i will have the response: 


{
 "@class": ".ChangeUserDetailsResponse",
 "error": {
  "DETAILS": "UNRECOGNISED"
 },
 "scriptData": null
}

Best Answer

Hi Damian,


You can use a ChangeUserDetailsRequest to add a password to the current DeviceAuthenticated account by sending your request like this.


{
 "@class": ".ChangeUserDetailsRequest",
 "displayName": "newDisplayName",
 "newPassword": "newPassword",
 "userName": "newUserName"
}

  

If you were getting Details Unrecognised in the response I'm guessing you included the oldPassword field in the request. Once you've done this successfully the player will have to log into the game with the new username and password. 


Thanks,

Liam


Hi Damien

To check if the name is already taken in unity you can use.

 

if(response.HasErrors)
{
	if(response.Errors.GetString("USERNAME") == "TAKEN");
	{
           //username is taken 
        }
}

 

The error DETAILS :UNRECOGNISED  means the  oldPassword did not match the one stored against the player.So make sure the old password you are using it correct.


Thanks

Katie

thank, for DETAILS :UNRECOGNISED device authentification does not use password, so we cannot update a device authenticated account ?

Answer

Hi Damian,


You can use a ChangeUserDetailsRequest to add a password to the current DeviceAuthenticated account by sending your request like this.


{
 "@class": ".ChangeUserDetailsRequest",
 "displayName": "newDisplayName",
 "newPassword": "newPassword",
 "userName": "newUserName"
}

  

If you were getting Details Unrecognised in the response I'm guessing you included the oldPassword field in the request. Once you've done this successfully the player will have to log into the game with the new username and password. 


Thanks,

Liam

well i just opened a fresh project and i can confirm doing so does not work there is a bug in your change user details request:


 

{
 "@class": ".ChangeUserDetailsResponse",
 "error": {
  "DETAILS": "UNRECOGNISED"
 },
 "scriptData": null
}
{
 "@class": ".ChangeUserDetailsRequest",
 "displayName": "tt",
 "language": "",
 "newPassword": "rty",
 "oldPassword": "",
 "userName": "rty"
}
{
 "@class": ".AuthenticationResponse",
 "authToken": "bf66e2a2-3dc2-471d-9c14-9cfa5dd20162",
 "newPlayer": true,
 "scriptData": null,
 "userId": "564daf826e7827b123448dc3"
}
{
 "@class": ".DeviceAuthenticationRequest",
 "deviceId": "",
 "deviceModel": "",
 "deviceName": "",
 "deviceOS": "",
 "deviceType": "",
 "displayName": "",
 "operatingSystem": "",
 "segments": {}
}
{
 "@class": ".AuthenticatedConnectResponse",
 "requestId": "0",
 "sessionId": "c7e80e0f-8378-4c93-9fd2-9266840d1877"
}
{
 "@class": ".AuthenticatedConnectRequest",
 "hmac": "2l6KnsfSbVksD8g8uqfqHbodIbqumNQekaYoSUAUJKI=",
 "platform": "Chrome",
 "os": "Mac"
}
{
 "@class": ".AuthenticatedConnectResponse",
 "nonce": "c7e80e0f-8378-4c93-9fd2-9266840d1877",
 "requestId": "0"
}
Connected

 

Hi Damian,


Can you confirm that you tried it like this ?

 

{
 "@class": ".ChangeUserDetailsRequest",
 "displayName": "tt",
 "language": "",
 "newPassword": "rty",
 "oldPassword": "",
 "userName": "rty"
}

 

If you did, it won't work, you have to completely remove the oldPassword field, try it like this (as mentioned above) and it will work. You can leave the language field in if you want.


{
 "@class": ".ChangeUserDetailsRequest",
 "displayName": "tt",
 "newPassword": "rty",
 "userName": "rty"
}

 


Thanks,

Liam

oh right it was because of the oldpassword = "", now it just works

Login to post a comment