1

I have double, triple checked the keys, the javascript sdk works great, but when I try to connect with the php sdk, i get Fatal error: Uncaught exception 'Parse\ParseException' with message 'unauthorized' when i try to login a user or do anything

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');

I am using the most recent version of the php-sdk, an alternative server running the javascvript sdk, connects and works fine.

1 Answer 1

2

You might find the keys are right but you not passing it on the constructor in parse-server. Make sure its in the parse-server config.

You can also try passing your REST_KEY in the initialize on both the php client side and through parse-server.

 ParseClient::initialize('YOUR_APP_ID', 'YOUR_REST_KEY', 'YOUR_MASTER_KEY');

Update for Heroku:

You need to add all the optional keys: restAPIKey, dotNetKey, clientKey, javascriptKey, to index.js as part of the initialization. Then you must set values for ALL of them. If even one of them is not set, restAPIKey is not enforced.

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
});
Sign up to request clarification or add additional context in comments.

7 Comments

can you please elaborate on the constructor? i am using herokus parse-server
@user3634054 in your case you can edit config vars from Settings tab in Heroku Dashboard.
Where appid is set, you need to make sure in the Heroku setting that you have that other keys there too.
I have added the JAVASCRIPT_KEY and REST_KEY to the heroku settings. I also added them to the index file with the link to the server vars.
So just make sure you set them all in the index.js file and pass the APP, REST, MASTER in php client side. This will work. Heroku will fail otherwise
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.