I'm having some trouble in executing a function because I keep getting the same error concerning my masterKey not being provided:
[PFCloud callFunctionInBackground:@"changeUserModeratorStatus" withParameters:@{@"objectId": self.objId}];
The function:
Parse.Cloud.define("changeUserModeratorStatus", function(request, response) {
Parse.Cloud.useMasterKey();
var query = new Parse.Query(Parse.User);
query.equalTo("objectId", request.params.objectId);
query.first({
success: function(anotherUser) {
anotherUser.set("ModeratorStatus", "Approved");
anotherUser.save(null, {
success: function(anotherUser) {
response.success("Successfully updated user.");
},
error: function(failedRetrieve, error) {
response.error("Could not save changes to user.");
}
});
},
error: function(error) {
response.error("Could not find user.");
}
});
});
Edit, i've literally copy/pasted Hectors example on the forums, checked the documents and haven't found a solution. No matter what I do, I get an error : Cannot use the Master Key, it has not been provided
You are probably missing the master key in the initialization of your cloud code -
Parse.initialize(applicationId, javaScriptKey, masterKey).
Taking out the whole initialization fixed the problem for me since Parse actually initializes your cloud code with your application id, JavaScript key and master key so you don't have to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With