parse.com - getSessionToken() not working in Parse -
below parse cloud code. unable user session when using master key. not possible user session if use mater key retrieve user?
parse.cloud.define("getfsusersession", getfsusersession); function getfsusersession(request, response) { parse.cloud.usemasterkey(); //removed codes here make short var someid = request.params.user; var query = new parse.query(parse.user); query.equalto('familysearchid', someid); query.ascending('createdat'); query.first({usemasterkey: true}).then(function (user) { console.log(typeof user.getsessiontoken());//this returns function console.log(user.getsessiontoken()); //this logs no message provided response.success(user.getsessiontoken()); }) }
i had disable require revocable sessions make work. after disabling require revocable sessions in settings can make api request /1/upgradetorevocablesession upgraded session token.
parse.cloud.define("getfsusersession", getfsusersession); function getfsusersession(request, response) { parse.cloud.usemasterkey(); //removed codes here make short var someid = request.params.user; var query = new parse.query(parse.user); query.equalto('familysearchid', someid); query.ascending('createdat'); query.first({usemasterkey: true}).then(function (user) { return parse.cloud.httprequest({ method: 'post', url: 'https://api.parse.com/1/upgradetorevocablesession', headers: { 'x-parse-application-id': parse.applicationid, 'x-parse-rest-api-key': restkey, 'x-parse-session-token': user.getsessiontoken() } }); }).then(function (httpresponse) { var sessionobject = httpresponse.data; if (sessionobject.sessiontoken) { return parse.promise.as(sessionobject.sessiontoken); } return parse.promise.error('unable session token'); }); }
Comments
Post a Comment