0
votes

I'm using Parse for the backend of my app and am trying to send notifications to a specific user using cloud code. I believe I've got everything set up correctly, however I am getting the following error:

Error: unauthorized: master key is required

Which is odd as the master key is being used as part of the cloud code below:

Parse.Cloud.define("pushOneFTC", async (request) => {
var query = new Parse.Query(Parse.Installation);
let userId = request.params.userId;
query.equalTo('userId', userId);

Parse.Push.send({
    where: query,
    data: {
        alert: "Fitcoins Gifted!",
        title: userId + " sent you 1 Fitcoin! Thats not a lot..."
    }
}).then(function() {
    // Push was successful
}, function(error) {
    // Handle error
}, {useMasterKey: true});
});

Have I missed something obvious here?

1
I think this is unnecessarily doubling up on your previous question Parse Cloud Code Invalid Function being called - see my latest edit - Tom Fox

1 Answers

0
votes

Please, try the code below:

Parse.Cloud.define("pushOneFTC", async (request) => {
var query = new Parse.Query(Parse.Installation);
let userId = request.params.userId;
query.equalTo('userId', userId);

Parse.Push.send({
    where: query,
    data: {
        alert: "Fitcoins Gifted!",
        title: userId + " sent you 1 Fitcoin! Thats not a lot..."
    }
}, {useMasterKey: true}).then(function() {
    // Push was successful
}, function(error) {
    // Handle error
});
});