I have set up the parse server on Heroku connected to MongoLab and I keep getting this even though the api key is correct.
gatewaysmacpro:parse-server-example gateway$ curl -X POST \
-H "X-Parse-Application-Id: XXXXXXXXXXXXXXXXXXXXXXX" \
-H "Content-Type: application/json" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
https://xxxxxx.herokuapp.com/parse/classes/GameScore
{"error":"unauthorized"}
gatewaysmacpro:parse-server-example gateway
any ideas what could be causing this?
check the route of api
Are you sure the appId is the same in your ParseServer initialization?
+1 mine dev environment in localhost instead of heroku, but same result
You also need to include the REST API Key or Parse-Master-Key in your POST request, I can see you've only included the Application Id, try adding one of the two to your request as below
-H "X-Parse-REST-API-Key: XXXXX" \
Or
-H "X-Parse-Master-Key: YOUR_APP_MASTER_KEY" \
@gateway in node_modules/parse/lib/node/CoreManager.js make sure SERVER_URL pointing to your server.
Closing as this hasn't been updated in a week and a solution seems to have been provided.
Just as a FYI, I ran into this problem when setting an App ID & Master Key, looking thru the code remember to create environment variables like:
APP_ID = your-app-secret
MASTER_KEY = your-master-key-secret
SERVER_URL = your-heroku-url/parse
curl -X POST \
-H "X-Parse-Application-Id: your-app-secret" \
-H "X-Parse-Master-Key: your-master-key-secret" \
-H "X-Parse-Url: https://your-heroku-url/parse" \
-H "Content-Type: application/json" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
https://your-heroku-url/parse/classes/GameScore
Once all setup and sent, curl should return:
{"objectId":"WBgSBMGl1Y","createdAt":"2016-05-27T15:32:16.410Z"}%
My curl post request works ok and returns the object id of newly created object, but curl GET requests return {"error":"unauthorized"} wtf
in CoreManager.js i changed the SERVER_URL to my server, didnt help
UPD:
i had a typo in my request, now everything is ok
Most helpful comment
Just as a FYI, I ran into this problem when setting an App ID & Master Key, looking thru the code remember to create environment variables like:
Once all setup and sent, curl should return:
{"objectId":"WBgSBMGl1Y","createdAt":"2016-05-27T15:32:16.410Z"}%