7

I'm using a standalone Parse server, trying to send a push notification to multiple Installations.

Parse Server won't let me query the Installation collection from Cloud Code, returning the following error:

Error handling request: ParseError {
  code: 119,
  message: 'Clients aren\'t allowed to perform the find operation on the installation collection.' } code=119, message=Clients aren't allowed to perform the find operation on the installation collection.

The query in Cloud Code looks like this:

var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.containedIn('user', users);
pushQuery.find({ ...

What's the proper way to get a list of Installations for a set of Users and send pushes to all of them?

I've also tried to get Cloud Code to use the masterKey by calling Parse.Cloud.useMasterKey(); immediately before the query. No effect and the master key is not included in the query request headers.

Gabriel Bauman
  • 2,270
  • 1
  • 22
  • 36
  • The error mentions clients aren't allowed to use the find query. How are you calling the cloud function from the client? – OneCricketeer Jan 12 '17 at 00:28
  • This is all in a Parse.Cloud.afterSave() callback. The client calls the server to update an object, and I'm trying to run this query after the save. The query is not run by the client directly. – Gabriel Bauman Jan 12 '17 at 00:37
  • weird that you are getting the client error then. Could you put the query somewhere other than the callback ? – Tom Schulz Jan 12 '17 at 00:46

1 Answers1

6

This is because Parse.Cloud.useMasterKey() is deprecated since Parse-server version 2.3.0. You now need to make use of useMasterKey: true in your query.

Eg:

var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.containedIn('user', users);
pushQuery.find({useMasterKey: true }).then(function(results) {
alvaro
  • 2,676
  • 2
  • 20
  • 19
Cliffordwh
  • 1,422
  • 1
  • 10
  • 18