Sign In Register

How can we help you today?

Start a new topic
Answered

Weird user creation

I was trying to link multiple devices to a single (facebook enabled) user account (which was indeed the first intent for this question), but I came up with this weird behaviour when I was gathering evidence.


This is what I did:


1. Remove all documents from the player collection

2. Device authentication:

{
 "@class": ".DeviceAuthenticationRequest",
 "deviceId": "PRUEBA_DEVICE_UNO",
 "deviceOS": "IOS"
}

A player document is successfully created 

{
 "_id": {
  "$oid": "554a58b11b3f58c687edc971"
 },
 "password": "pWCL7DfETNrTLPAr6Rwj/IYN00m4lSvjmVMDKxGYC0w=",
 "userName": "289583-IOS-PRUEBA_DEVICE_UNO",
 "gameId": {
  "$numberLong": "289583"
 },
 "location": {
  "latitide": 25.666702270507812,
  "longditute": -100.4000015258789,
  "city": "Garza García",
  "country": "MX"
 },
 "currency1": {
  "$numberLong": "0"
 },
 "currency2": {
  "$numberLong": "0"
 },
 "currency3": {
  "$numberLong": "0"
 },
 "currency4": {
  "$numberLong": "0"
 },
 "currency5": {
  "$numberLong": "0"
 },
 "currency6": {
  "$numberLong": "0"
 },
 "authTokens": [
  "49dcb0ce-2d35-4552-ab1f-8499fb853f6d#0"
 ],
 "online": true,
 "lastSeen": {
  "$date": {
   "$numberLong": "1430935729574"
  }
 }
} 

 3. Facebook authentication:

{
 "@class": ".FacebookConnectRequest",
 "accessToken": “sOMeaCcessTOkeN”
}

   Result: I have the following two player documents:

{
 "_id": {
  "$oid": "554a58b11b3f58c687edc971"
 },
 "password": "pWCL7DfETNrTLPAr6Rwj/IYN00m4lSvjmVMDKxGYC0w=",
 "userName": "289583-IOS-PRUEBA_DEVICE_UNO",
 "gameId": {
  "$numberLong": "289583"
 },
 "location": {
  "latitide": 25.666702270507812,
  "longditute": -100.4000015258789,
  "city": "Garza García",
  "country": "MX"
 },
 "currency1": {
  "$numberLong": "0"
 },
 "currency2": {
  "$numberLong": "0"
 },
 "currency3": {
  "$numberLong": "0"
 },
 "currency4": {
  "$numberLong": "0"
 },
 "currency5": {
  "$numberLong": "0"
 },
 "currency6": {
  "$numberLong": "0"
 },
 "authTokens": [
  "49dcb0ce-2d35-4552-ab1f-8499fb853f6d#0"
 ],
 "online": false,
 "lastSeen": {
  "$date": {
   "$numberLong": "1430935729574"
  }
 }
}

 

{
 "_id": {
  "$oid": "554a584de4b079dbaafe9a6a"
 },
 "authTokens": [
  "c95344d5-fab0-4577-92cb-f99b0cd88077#1",
  "5a1c3ee3-913f-4273-a083-aeefd433b982#0"
 ],
 "online": true,
 "lastSeen": {
  "$date": {
   "$numberLong": "1430935796571"
  }
 }
}

  

So there are many questions here:

  1. Why is a second player created?
  2. Which one is linked to Facebook?
  3. Where is the displayName of the player that just authenticated?
  4. And finally... is it possible to link further devices to my user?

Thanks in advance!

Best Answer

Hi Guys,


When authenticating with an external social account you need to set doNotLinkToCurrentPlayer to false to link the social account you are authenticating with to the current authenticated player. In Eduardos example above, he was not doing this, he was just sending the token in the FacebookConnectRequest that would result in a new player being created. Sanghoon if you are doing some tests and removing players from the system player collection in the NoSql explorer manually, you will also need to remove the matching document for the deleted player from the externalAuthentication collection. It should work fine then. System collections are read only you you can't write to them manually.


Thanks,

Liam


Any answers about this?


I'm trying again today. Again: first device authentication, next Facebook authentication; the result now are two players created.


To reproduce:


1. Device Authentication

{
 "@class": ".DeviceAuthenticationRequest",
 "deviceId": "TEST_DEVICE_ONE",
 "deviceOS": "IOS"
}

 2. Facebook Authentication:

{
 "@class": ".FacebookConnectRequest",
 "accessToken": "CAAL1hn5MYtcBALi8zpLwpkZCsYXKvXVuhEORZCAROKQiPMlWqameJxXfUKInypY1VSkiNQefh0HlkDd8rSoynCj6DiKOAQUUH73dLrjUhGGNU2FmpZAsOwrXsqjYxbkyCHJQy3aYuNSmx4ZCeHim2xBbMzu3WQiPmjHBmdzTu9W4wmWaWnjZCfE1ZAXDn2XnPov2ZCn3AZAG9iZBPL6k3pjqb"
}

 Result: Two players created:

 

{
 "_id": {
  "$oid": "554c073f1b3f58c687edcb96"
 },
 "password": "vLN9Cs/ToQQplA1zU/xJOFOsBOHP/RCFAggfAg/n5pY=",
 "userName": "289583-IOS-TEST_DEVICE_ONE",
 "gameId": {
  "$numberLong": "289583"
 },
 "location": {
  "latitide": 19.4342041015625,
  "longditute": -99.13860321044922,
  "city": "Mexico",
  "country": "MX"
 },
 "currency1": {
  "$numberLong": "0"
 },
 "currency2": {
  "$numberLong": "0"
 },
 "currency3": {
  "$numberLong": "0"
 },
 "currency4": {
  "$numberLong": "0"
 },
 "currency5": {
  "$numberLong": "0"
 },
 "currency6": {
  "$numberLong": "0"
 },
 "authTokens": [
  "f5b96525-48e1-4d49-9f43-b214b1929d77#0"
 ],
 "online": false,
 "lastSeen": {
  "$date": {
   "$numberLong": "1431045951978"
  }
 }
}

 

{
 "_id": {
  "$oid": "554c0749e4b0c1702aa66b5d"
 },
 "gameId": {
  "$numberLong": "289583"
 },
 "deviceRegIds": {},
 "segments": {},
 "goods": {},
 "achievements": [],
 "reservedCurrency1": {},
 "reservedCurrency2": {},
 "reservedCurrency3": {},
 "reservedCurrency4": {},
 "reservedCurrency5": {},
 "reservedCurrency6": {},
 "authTokens": [
  "a63c693c-29d1-41ae-ab02-6314bf150d36#0"
 ],
 "location": {
  "latitide": 19.4342041015625,
  "longditute": -99.13860321044922,
  "city": "Mexico",
  "country": "MX"
 },
 "userName": "FB_1388744301454096",
 "displayName": "John Smith",
 "online": true,
 "scriptData": {},
 "privateData": {},
 "externalAuthentications": {
  "FB": {
   "$oid": "554a4d4be4b0c1702a9bd644"
  }
 },
 "externalIds": {
  "FB": "1388744301454096"
 },
 "created": {
  "$date": {
   "$numberLong": "1431045961592"
  }
 },
 "currency1": {
  "$numberLong": "0"
 },
 "currency2": {
  "$numberLong": "0"
 },
 "currency3": {
  "$numberLong": "0"
 },
 "currency4": {
  "$numberLong": "0"
 },
 "currency5": {
  "$numberLong": "0"
 },
 "currency6": {
  "$numberLong": "0"
 },
 "lastSeen": {
  "$date": {
   "$numberLong": "1431045962190"
  }
 }
}

  

+1 this ticket.


As I'm trying to connect multiple social services to one account,

but it keep creating new player account per each social service.


Do I need to do something?

Such as modifying these in player collection manually with cloud code?


"externalAuthentications": {  "FB": {   "$oid": "554a4d4be4b0c1702a9bd644"  }  }, "externalIds": {  "FB": "1388744301454096" },

I found out.


NoSQL "externalAuthentication" collection has information of previous connection of external services.

It seems restoring old user, not creating new user. But as player collection removed, it looks like it creates one new account.


Answer

Hi Guys,


When authenticating with an external social account you need to set doNotLinkToCurrentPlayer to false to link the social account you are authenticating with to the current authenticated player. In Eduardos example above, he was not doing this, he was just sending the token in the FacebookConnectRequest that would result in a new player being created. Sanghoon if you are doing some tests and removing players from the system player collection in the NoSql explorer manually, you will also need to remove the matching document for the deleted player from the externalAuthentication collection. It should work fine then. System collections are read only you you can't write to them manually.


Thanks,

Liam

Login to post a comment