Skip to content

Parse Query returns 141 unauthorized error #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
refre5h opened this issue Feb 12, 2016 · 6 comments
Closed

Parse Query returns 141 unauthorized error #54

refre5h opened this issue Feb 12, 2016 · 6 comments

Comments

@refre5h
Copy link

refre5h commented Feb 12, 2016

Followed the example and finished setting up Heroku and MongoDB. These 3 all worked:

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:5000/parse/classes/GameScore
curl -X GET \
  -H "X-Parse-Application-Id: myAppId" \
  -H "X-Parse-Master-Key: myMasterKey" \
  http://localhost:5000/parse/classes/GameScore
curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  http://localhost:5000/parse/functions/hello

I then wrote a simple query to get the GameScore class data:

Parse.Cloud.define('getGameScore', function(req, res) {
    var query = new Parse.Query("GameScore");
    query.find().then(function(results){
        res.success(results);
    },function(error){
        res.error(error);
    })
})

... and tried to call the function with this:

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  http://localhost:5000/parse/functions/getGameScore

... got this error:
{"code":141,"error":{"message":"unauthorized"}}

screen shot 2016-02-11 at 5 10 46 pm

Am I missing anything, or is this a bug?

@ghost
Copy link

ghost commented Feb 12, 2016

No. you missed your application id and master key parse.com below on your code.

@drew-gross
Copy link
Contributor

Do you have any client keys set in your server configuration? If you do, you will need to provide one of them in your request. You can also remove the client keys from your server configuration, as they are unnecessary in parse-server.

@refre5h
Copy link
Author

refre5h commented Feb 12, 2016

@estylehq I did include the app id in the examples I provided. I also just tried including the master key, but it still gave the same error.
screen shot 2016-02-11 at 11 36 41 pm

@drew-gross I don't have any client keys set in the server config. Below you can see my config and constructor.
screen shot 2016-02-11 at 11 26 52 pm
screen shot 2016-02-11 at 11 29 34 pm

Another reason why I suspect this could be a bug is that the "hello" function works, but not the "getGameScore".

// CALLING THIS ONE WORKED
Parse.Cloud.define('hello', function(req, res) {
  res.success('Hello from the other side!');
});
// CALLING THIS GAVE THE ERROR
Parse.Cloud.define('getGameScore', function(req, res) {
    var query = new Parse.Query("GameScore");
    query.find().then(function(results){
        res.success(results);
    },function(error){
        res.error(error);
    })
})

@refre5h
Copy link
Author

refre5h commented Feb 12, 2016

I have found the solution here: ParsePlatform/parse-server/issues/356
Turns out I need to add the serverURL option.

@refre5h refre5h closed this as completed Feb 12, 2016
@simonbengtsson
Copy link

I think the serverURL should either be included in the example or stressed more in the documentation.

@liangjun-jiang
Copy link

strongly agreed @simonbengtsson . it takes me another 15 mins to figure this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants