parse-community / parse-php-sdk

The PHP SDK for Parse Platform
https://parseplatform.org/
Other
811 stars 346 forks source link

"unauthorized: master key is required" error on aggregate ParseQuery despite the master key is set #466

Open dueldanov opened 4 years ago

dueldanov commented 4 years ago

Issue Description

I get "unauthorized: master key is required" error when I try to do aggregate ParseQuery as below.

ParseClient::initialize('appId', null, 'masterKey');
ParseClient::setServerURL('https://example.com', 'mountPath');

$pipeline = [
    'group' => [
        'userAttached' => $userId,
        'total' => [ '$sum' => 1]
    ]
];

$query = new ParseQuery("Financials");
$query->equalTo("company_id", $companyId);
$query->equalTo("type", "income");

try {
    $resultSum = $query->aggregate($pipeline);
    print_r($resultSum);
} catch (ParseException $ex) {
    echo $ex->getMessage();
}

As you can see master key is already set, can't find what may be the issue.

Environment Details