Skip to content

Instantly share code, notes, and snippets.

@agramonte
Last active June 28, 2017 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agramonte/bf791c5f7dde2ce7b5b6c1f667002ae2 to your computer and use it in GitHub Desktop.
Save agramonte/bf791c5f7dde2ce7b5b6c1f667002ae2 to your computer and use it in GitHub Desktop.
//Login URL:
//https://preview.gamesparks.net/callback/<yourAPIKey>/userLogin/<yourCredentialSecret>?username=<username>&password=<password>
//Register URL:
//https://preview.gamesparks.net/callback/<yourAPIKey>/register/<yourCredentialSecret>?username=<username>&password=<password>&displayName=<displayName>
//The login code:
var uPwd = Spark.getData().password;
var uName = Spark.getData().username;
var authenticationResponse = Spark.sendRequest(
{
"@class": ".AuthenticationRequest",
"password": uPwd,
"userName": uName
}
)
if (authenticationResponse.error == null) {
Spark.setScriptData("RESPONSE_RAW", '{"Status":"Success"}');
} else {
Spark.getLog().error(authenticationResponse)
Spark.setScriptData("RESPONSE_RAW", '{"Status": ""}');
}
//The register code:
var uPwd = Spark.getData().password;
var uName = Spark.getData().username;
var dName = Spark.getData().displayname;
var registrationResponse = Spark.sendRequest(
{
"@class": ".RegistrationRequest",
"displayName": uName,
"password": uPwd,
"segments": {},
"userName": uName
}
)
if (registrationResponse.error == null) {
Spark.setScriptData("RESPONSE_RAW", '{"Status":"Success"}');
} else {
Spark.getLog().error(registrationResponse)
Spark.setScriptData("RESPONSE_RAW", '{"Status": ""}');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment