Local cloud setup - spark setup returning server_error

Hi all, I was setting up local cloud for spark core, following the instruction in this post http://community.spark.io/t/tutorial-local-cloud-1st-time-instructions-03-march-15/5589

I was stuck at the “spark setup” step. When I ran “spark setup”, it gave me this

========================================
Setup your account

Could I please have an email address? albert.pang@me.com
and a password? ********

Trying to login…
Could not get new access token: server_error
login error: server_error
Error setting up your core: Unable to login or create a new account

Tried repeating the procedure a couple of times but no luck. At the end, I stepped through the spark-cli code and found that it actually successfully went to the server to try login first. Server said there were no users created and returned an error “login error: server_error” (users directory is empty so it never read any file into the user profile array). I expected spark-cli it to then ask me to create a new account, but it never did, instead, it just exited with the above error message. I checked the config file and saw that the access_token written to it is actually “Login error: server_error”

Stepping through the code, I think it’s because of the login function in spark-cli ApiClient.js:

login: function (client_id, user, pass) {
var that = this;

  return this.createAccessToken(client_id, user, pass).then(function(resp) {
  	console.log("Got an access token! " + resp.access_token);
  	that._access_token = resp.access_token;
  	return that._access_token;
  }).catch(function (err) {
  	console.error("login error: ", err);
  	return("Login Failed: " + err);
  });

},

After it logs the error in the console, it actually returns “Login Failed: …” to the caller. The caller is in SetupCommand.js:

  		when(loginDone).then(
  			function (token) {
  				if (username) {
  					settings.override(null, "username", username);
  				}
  				//login success
  				tmp.resolve(token);
  			},
  			function () {
  				var username = creds[0];
  				if (!username || (username == '')
  					|| (!utilities.contains(username, "@"))
  					|| (!utilities.contains(username, "."))) {
  					tmp.reject("Username must be an email address.");
  					return;
  				}
  				console.log("Login failed, Lets create a new account!");

It went into the success function (the one with the comment “//login success” in it), rather than the failure function which is where the code for creating a new account is.

I changed the return statement in the login function to be a reject call, like so:

login: function (client_id, user, pass) {
var that = this;

  return this.createAccessToken(client_id, user, pass).then(function(resp) {
  	console.log("Got an access token! " + resp.access_token);
  	that._access_token = resp.access_token;
  	return that._access_token;
  }).catch(function (err) {
  	console.error("login error: ", err);
  	reject( error );
  	// return("Login Failed: " + err);
  });

},

After that it went into the code for creating a new account as I would have expected it to and I was able to move on. I took the spark-cli code and spark-server code by git clone. So that should be the latest as of yesterday.

Searching through the forum, I don’t seem to see anyone having problem with spark setup. So I wondered why only me got this problem. Am I using the wrong version of the code or have I perhaps missed some steps when setting up the server to first create users before calling “spark setup”?

Any ideas? Thanks in advance!

Cheers,
Albert

Similar issue here: https://community.spark.io/t/tutorial-local-cloud-1st-time-instructions-03-march-15/5589/89

1.) Downgrade to V0.4.94

2.) or modify Spark-cli with this PR changes: https://github.com/spark/spark-cli/pull/164