question

Grant McNamara avatar image
Grant McNamara asked

How do i get the entity token for the x-validation?

I keep trying to get the entity token but i can never get it to work and i dont know why.

THis is my current login form

```

function Login()
// fetch input data
var id = "D4589";
var username = document.getElementById('username').value;
var password = document.getElementById('password').value;
if(!id || id == "")
OutputError("TitleId cannot be null");
return;
else if(typeof PlayFab == 'undefined') // make sure we have the SDK prior to calling / setting
OutputError("The PlayFab SDK could not be found. Double check your script sources");
return;
// save these values locally to ease use
localStorage.titleId = id;
// save title id
PlayFab.settings.titleId = id;
// build http request object for LoginWithCustomId
var LoginWithPlayFabRequest = {};
LoginWithPlayFabRequest.TitleId = id;
LoginWithPlayFabRequest.Password = password;
LoginWithPlayFabRequest.Username = username;
OutputStatus("Logging in...");
PlayFabClientSDK.LoginWithPlayFab(LoginWithPlayFabRequest, (response, error) => {
if(error)
OutputError(error);
else
// display account details
var result = response.data;
var status = "Login Successful. <br \\> Welcome: " +username+"<br \\>"+result.EntityToken;
OutputStatus(status);

```

All the code does is display [object OBJECT]

entities
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

According to LoginWithCustomID, "result.EntityToken" is an object. What you need is "result.EntityToken.EntityToken".

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.