parse-php-sdk Fatal error: Uncaught exception 'Parse\ParseException' with message 'unauthorized'

parse-php-sdk Fatal error: Uncaught exception 'Parse\ParseException' with message 'unauthorized'

我对密钥进行了双重、三次检查,javascript sdk 运行良好,但是当我尝试连接 php sdk 时,出现致命错误:未捕获异常 'Parse\ParseException' 消息 'unauthorized' 当我尝试登录用户或做任何事情时

require ("parse-php-sdk-master/autoload.php");
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
use Parse\ParseClient;
ParseClient::initialize("secret","secret","secret");
ParseClient::setServerURL('https://serveraddress.herokuapp.com','parse');

我正在使用最新版本的 php-sdk,替代服务器 运行 javascvript sdk,连接并工作正常。

您可能会发现密钥是正确的,但您没有将其传递给 parse-server 中的构造函数。确保它在 parse-server 配置中。

您也可以尝试在 php 客户端和通过 parse-server.

的初始化中传递您的 REST_KEY
 ParseClient::initialize('YOUR_APP_ID', 'YOUR_REST_KEY', 'YOUR_MASTER_KEY');

Heroku 更新

您需要将所有可选键:restAPIKeydotNetKeyclientKeyjavascriptKey 添加到 index.js 作为初始化的一部分。然后您必须为所有这些设置值。如果其中之一未设置,则不强制执行 restAPIKey

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'myAppId',
  masterKey: process.env.MASTER_KEY || '',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337',
  javascriptKey: process.env.JAVASCRIPT_KEY || '',  //** add this line no need to set values, they will be overwritten by heroku config vars
  restAPIKey: process.env.REST_API_KEY || '', //** add this line
  dotNetKey: process.env.DOT_NET_KEY || '', //** add this line
  clientKey: process.env.CLIENT_KEY || '', //** add this line
});