i got a Problem with managing my account creation and login.
Currently i got 2 Solutions which both have flaws i cant fix:
1. At first app start, i ask the user to login through FB/G+; or to enter a username and then login through deviceregister and i save that he is registered through deviceregister in the playerprefs so the next app start i can just authenticate through device.
Problem is now when he reinstalls the app or deletes the playerprefs, i dont know if he connected through device. I would need to know if any account uses his deviceID withouth creating an Account. Something like an optional parameter in DeviceAuthentication DontCreateNewAccountWhenDeviceNotRegistered :D
Or can i somehow get through cloudcode if the deviceID is in use ?
2. I call authenticateWithDevice at app Start, if a new account is created, i ask for a username or a connect through FB/G+.
Here are several Problem; when he connects through FB/G+ and he has an account allready, the freshly created account will just be a "dead-account". And how do i unbound deviceIDs from accounts when he switches to another Phone and sells his old one ?
Or is there a simpler solution and i missuse a feature ?
Regards
Best Answer
T
Tech Support
said
about 4 years ago
Device authentication isn't something you can link or delink unfortunately because it's saved in the userName:
GameID-Platform-DeviceUniqueID
for example:
293711-W8-exampleUniqueDeviceID
If you want to access it in the database using Device Authentication request Cloud Code, this is the way to do it
//GameID + deviceOS + deviceID
var deviceUserName = "293711-" + Spark.getData().deviceOS + "-" + Spark.getData().deviceId;
//Load player collection
var players = Spark.systemCollection("player");
//Find user with that username
var playerId = players.findOne({"userName" : deviceUserName}, {_id : 1});
//Load player
var player = Spark.loadPlayer(playerId._id.$oid);
However, again, you can't delink it, because it's part of the user now. You can only manually delete all the data attached to that player or delete the player.
1- If a player signs in with a device ID from a a phone without a playerpref file (Meaning first time or playerpref was deleted) You want to check if the device ID is connected to social account or if it even exists.
Keep me updated and we can work on the best solution for you.
Hope this helps,
Omar
F
Fabian Kuhn
said
about 4 years ago
Hello Omar, Thanks for your answer !
Maybe i should set a more precise question:
How do i check in CloudCode (in DeviceAuthenticationRequest), if the given deviceID is allready in use for another player or if this deviceID is new.
And is it possible to disconnect a deviceID from an account ?
Regards !
Tech Support
said
about 4 years ago
Hi Fabian,
I think this approach might help you:
1- When player makes a Device Auth request the game check for the playerPref file.
2- If the playerPref file exists then you send a boolean set to 'True' in the Device Auth scripData, if the playerPref file does not exist then you send a 'Flase' value.
3- When the boolean(Let's name it condition) is received by Cloud Code and it's false(No playerPref associated with player) then we run some logic to remove connected social accounts.
This is the way I've done it:
The Device Auth request sent from the Test Harness:
{
"@class": ".DeviceAuthenticationRequest",
"deviceId": "testGS",
"deviceOS": "UE4",
"scriptData": {
"condition": false
}
}
When that scriptData makes it into the request as false, we'll forward it to the response:
//Get condition
var condition = Spark.getData().scriptData.condition;
//If condition is false meaning no playerPref, we're going to remove social accounts linked
if(condition == false){
Spark.setScriptData("condition", condition);
}
When that data makes it to the response we want to check if that player exists, if it exists then we want to unlink social profiles linked to it, for example FB:
//Get the Data associated with this request, including scriptData forwarded from request
var dataExample = Spark.getData();
//Check if condition exists
if(dataExample.condition !== null){
//If so then diconnect social profiles
if(!Spark.getData().newPlayer){
var socialRequest = new SparkRequests.SocialDisconnectRequest();
//FB is one example, please check API doc for more options
Hope this basic example sheds some light on the process. If you need anymore help please let us know.
Cheers,
Omar
F
Fabian Kuhn
said
about 4 years ago
Hell Omar,
i think u missunderstand my Problem.
There are several Problems to your solution:
What if Player A owns Device A, plays the game, and sells the Device to Player B (Both player use DeviceReigster). Player B wouldnt be able to make a new Account, since Device A is linked to Players A Account, he cant delink his Account.
So a question would be 1. How do i unlink a device ID from an Account?
I would like to link and delink a deviceID like a link and delink a Facebook connection, is that possible ?
Another Problem is the usage of multiple Devices: Player A has and Account created with Device A. Now he owns Device B and tries to login through Facebook. Device B has no playerPrefs and creates a new Account, but switches it to Facebook. The newly created Account is now a "dead-account". Only if Device B logs out of Facebook and logs in through DeviceID, it can retrieve this newly created Account.
To prevent this, i would like to find out through Cloud Clode (through a query or sth), if a DeviceID is allready in use or if this deviceID is new, is that possible ?
If i couold solve those questions i would have everything i need !
Regards
Tech Support
said
about 4 years ago
Answer
Device authentication isn't something you can link or delink unfortunately because it's saved in the userName:
GameID-Platform-DeviceUniqueID
for example:
293711-W8-exampleUniqueDeviceID
If you want to access it in the database using Device Authentication request Cloud Code, this is the way to do it
//GameID + deviceOS + deviceID
var deviceUserName = "293711-" + Spark.getData().deviceOS + "-" + Spark.getData().deviceId;
//Load player collection
var players = Spark.systemCollection("player");
//Find user with that username
var playerId = players.findOne({"userName" : deviceUserName}, {_id : 1});
//Load player
var player = Spark.loadPlayer(playerId._id.$oid);
However, again, you can't delink it, because it's part of the user now. You can only manually delete all the data attached to that player or delete the player.
Hope this makes things clearer,
Omar
1 person likes this
F
Fabian Kuhn
said
about 4 years ago
Thank you Omar this is exactly what i was looking for !
Have a nice day :)
Tech Support
said
about 4 years ago
Hey Fabian,
Glad that helped,
you can also change the userName using the changeDetailsRequest.
Fabian Kuhn
Hello,
i got a Problem with managing my account creation and login.
Currently i got 2 Solutions which both have flaws i cant fix:
1. At first app start, i ask the user to login through FB/G+; or to enter a username and then login through deviceregister and i save that he is registered through deviceregister in the playerprefs so the next app start i can just authenticate through device.
Problem is now when he reinstalls the app or deletes the playerprefs, i dont know if he connected through device. I would need to know if any account uses his deviceID withouth creating an Account. Something like an optional parameter in DeviceAuthentication DontCreateNewAccountWhenDeviceNotRegistered :D
Or can i somehow get through cloudcode if the deviceID is in use ?
2. I call authenticateWithDevice at app Start, if a new account is created, i ask for a username or a connect through FB/G+.
Here are several Problem; when he connects through FB/G+ and he has an account allready, the freshly created account will just be a "dead-account". And how do i unbound deviceIDs from accounts when he switches to another Phone and sells his old one ?
Or is there a simpler solution and i missuse a feature ?
Regards
Device authentication isn't something you can link or delink unfortunately because it's saved in the userName:
GameID-Platform-DeviceUniqueID
for example:
293711-W8-exampleUniqueDeviceID
If you want to access it in the database using Device Authentication request Cloud Code, this is the way to do it
//GameID + deviceOS + deviceID
var deviceUserName = "293711-" + Spark.getData().deviceOS + "-" + Spark.getData().deviceId;
//Load player collection
var players = Spark.systemCollection("player");
//Find user with that username
var playerId = players.findOne({"userName" : deviceUserName}, {_id : 1});
//Load player
var player = Spark.loadPlayer(playerId._id.$oid);
However, again, you can't delink it, because it's part of the user now. You can only manually delete all the data attached to that player or delete the player.
Hope this makes things clearer,
Omar
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstTech Support
Hi Fabian, from what I understand:
1- If a player signs in with a device ID from a a phone without a playerpref file (Meaning first time or playerpref was deleted) You want to check if the device ID is connected to social account or if it even exists.
I think this will interest you - https://docs.gamesparks.com/api-documentation/request-api/player/socialdisconnectrequest.html
Also this tutorial will teach you how to place logic in an Authentication Request and process information and potentially cancel it before it goes through - https://docs.gamesparks.com/tutorials/social-authentication-and-player-profile/automating-user-password-change.html
Keep me updated and we can work on the best solution for you.
Hope this helps,
Omar
Fabian Kuhn
Hello Omar, Thanks for your answer !
Maybe i should set a more precise question:
How do i check in CloudCode (in DeviceAuthenticationRequest), if the given deviceID is allready in use for another player or if this deviceID is new.
And is it possible to disconnect a deviceID from an account ?
Regards !
Tech Support
Hi Fabian,
I think this approach might help you:
1- When player makes a Device Auth request the game check for the playerPref file.
2- If the playerPref file exists then you send a boolean set to 'True' in the Device Auth scripData, if the playerPref file does not exist then you send a 'Flase' value.
3- When the boolean(Let's name it condition) is received by Cloud Code and it's false(No playerPref associated with player) then we run some logic to remove connected social accounts.
This is the way I've done it:
The Device Auth request sent from the Test Harness:
{
"@class": ".DeviceAuthenticationRequest",
"deviceId": "testGS",
"deviceOS": "UE4",
"scriptData": {
"condition": false
}
}
When that scriptData makes it into the request as false, we'll forward it to the response:
//Get condition
var condition = Spark.getData().scriptData.condition;
//If condition is false meaning no playerPref, we're going to remove social accounts linked
if(condition == false){
Spark.setScriptData("condition", condition);
}
When that data makes it to the response we want to check if that player exists, if it exists then we want to unlink social profiles linked to it, for example FB:
//Get the Data associated with this request, including scriptData forwarded from request
var dataExample = Spark.getData();
//Check if condition exists
if(dataExample.condition !== null){
//If so then diconnect social profiles
if(!Spark.getData().newPlayer){
var socialRequest = new SparkRequests.SocialDisconnectRequest();
//FB is one example, please check API doc for more options
socialRequest.systemId = "FB";
//Finally send this request on behalf of player
socialRequest.SendAs(Spark.getPlayer().getPlayerId());
}
}
Hope this basic example sheds some light on the process. If you need anymore help please let us know.
Cheers,
Omar
Fabian Kuhn
Hell Omar,
i think u missunderstand my Problem.
There are several Problems to your solution:
What if Player A owns Device A, plays the game, and sells the Device to Player B (Both player use DeviceReigster). Player B wouldnt be able to make a new Account, since Device A is linked to Players A Account, he cant delink his Account.
So a question would be 1. How do i unlink a device ID from an Account?
I would like to link and delink a deviceID like a link and delink a Facebook connection, is that possible ?
Another Problem is the usage of multiple Devices: Player A has and Account created with Device A. Now he owns Device B and tries to login through Facebook. Device B has no playerPrefs and creates a new Account, but switches it to Facebook. The newly created Account is now a "dead-account". Only if Device B logs out of Facebook and logs in through DeviceID, it can retrieve this newly created Account.
To prevent this, i would like to find out through Cloud Clode (through a query or sth), if a DeviceID is allready in use or if this deviceID is new, is that possible ?
If i couold solve those questions i would have everything i need !
Regards
Tech Support
Device authentication isn't something you can link or delink unfortunately because it's saved in the userName:
GameID-Platform-DeviceUniqueID
for example:
293711-W8-exampleUniqueDeviceID
If you want to access it in the database using Device Authentication request Cloud Code, this is the way to do it
//GameID + deviceOS + deviceID
var deviceUserName = "293711-" + Spark.getData().deviceOS + "-" + Spark.getData().deviceId;
//Load player collection
var players = Spark.systemCollection("player");
//Find user with that username
var playerId = players.findOne({"userName" : deviceUserName}, {_id : 1});
//Load player
var player = Spark.loadPlayer(playerId._id.$oid);
However, again, you can't delink it, because it's part of the user now. You can only manually delete all the data attached to that player or delete the player.
Hope this makes things clearer,
Omar
1 person likes this
Fabian Kuhn
Thank you Omar this is exactly what i was looking for !
Have a nice day :)
Tech Support
Hey Fabian,
Glad that helped,
you can also change the userName using the changeDetailsRequest.
Hope this helps,
Omar
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2485 topics