Skip to content
This repository was archived by the owner on Oct 31, 2021. It is now read-only.

Conversation

@achimkoellner
Copy link

I'd love to use node-parse-api with a logged-in user. The node server receives a sessionToken from the client and performs database operations on behalf of that session.
For that purpose the session_token (besides app_key and api_key) can be passed to the constructor.

If no sessionToken is passed to the parseRequest method by argument, the method checks if the constructor options contain a session_token value and sends an X-Parse-Session-Token header with the request.

This allows e.g. to find objects of classes that are restricted to be read by only that user (or role).

// example usage
var Parse = require('node-parse-api').Parse;

// let's assume this is a sessionToken of an user who is member of the role "moderator"
var sessionToken = '3h3gaa32bdd3h3gaa323h3gaa32bddbdd';

var options = {
    app_id:'...',
    api_key:'...',
    session_token: sessionToken // , master_key:'...' could be used too 
}

var app = new Parse(options);

// let's assume Foo is a class with read permission for "moderator"-users only
app.find('Foo', {objectId: 'someId'}, function (err, response) {
    console.log(response);
});

JoJordens and others added 30 commits April 22, 2015 10:49
Session tokens only work with the rest api key. While using the master key you can edit all data anyway.
Parse.test.js runs tests against the master key, while testRestApiKey.js runs tests against the rest api key to test sesstion tokens for users.
getUser and getFileByUser now redirect to their respective newer version while logging a warning message to the console.
Also removes one console.log from Parse.test.js and adds one more contributor.
Optimizes and adds some methods
allow posting arbitrary data to /installations
I read somewhere that this is better and it has personally prevented the "[Error: getaddrinfo ENOTFOUND api.parse.com]" error I get occasionally.
Changed the parse options variable "host" field to "hostname"
Without a timeout set, the socket can "hang" waiting for a response.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.