bharal
bharal

Reputation: 16174

Parse.com: How do I return the session token?

I've created a signUp function for my app to call, and the Parse.com backend JS code to sign the user up.

Sure enough, the user will appear in the database. Heck, I even got the verification email to be sent (something that was much harder than it should be. It is a setting under the "settings" section of the main parse backend, not something that is programatically set).

Now I'm trying to get the sessionToken from the newly signed up user. Returning the "user" object on success of the signup and inspecting, I don't see a "sessionToken". I also don't see a sessionToken in the user database...

Can somebody give me some code that will return the sessionToken?

Here is the relevant code:

user.signUp(null, {
  success: function(user) {
    response.success(user);
  },
  error: function(user, error) {
    alert("Error: " + error.code + " " + error.message);
  }
});

I don't get a sessionToken here. Where do I get it from?

Upvotes: 6

Views: 8588

Answers (2)

bharal
bharal

Reputation: 16174

The code i ended up using looked something like this:

endpoint : "https://api.parse.com/1/login",
    parameters : getTheLoginParametersFrom(user),
    success : function(response) {
        tablesModule.saveSessionId(response.sessionToken);
    }
}

Where the result from the "login" is the response.sessionToken.

Upvotes: 0

Arcayne
Arcayne

Reputation: 1186

I think you need to check on your local storage:

Local Storage Report

There are 5 items in local storage, using 0.9KB (0.001MB)

Parse/bqfSO3dVttG65a8CIkC1SdqC0CCqiqYsp1EfsjL8/currentUser

username [email protected]
email [email protected]
objectId oVGKr1vdbG
createdAt 2013-03-20T17:17:54.815Z
updatedAt 2013-03-20T17:17:54.815Z
_id oVGKr1vdbG
_sessionToken 12aob7us2lj18pkaddkbvsal7

That is what Parse checks when you do:

var currentUser = Parse.User.current();
var sessionToken = Parse.User.current()._sessionToken;

Upvotes: 6

Related Questions