Skip to content
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

"error":"unauthorized" on debian 8.3.0 #477

Closed
maurosoft1973 opened this issue Feb 18, 2016 · 7 comments
Closed

"error":"unauthorized" on debian 8.3.0 #477

maurosoft1973 opened this issue Feb 18, 2016 · 7 comments

Comments

@maurosoft1973
Copy link

Hello!
I installed Node.js (version 5.6.0) and mongodb on a virtual machine.

To check if the environment works, I tried to enter from console:
curl -X POST -H 'X-Parse-Application-Id: AppId "-H" Content-Type: application / json "-d' {" score ": 1337," playername ":" Sammy "," cheatMode ": false} 'http://localhost:1337/parse/classes/gamescore where to AppId I replaced my AppId.
I always get the following error: {"error": "unauthorized"}

I created a virtual machine with Windows Server 2012, the same configuration for nodejs and mongo, testing the same script,it's works.

I do not understand why

@Kira2
Copy link
Contributor

Kira2 commented Feb 18, 2016

Hi,

Can you check that the index.js are the same into your two servers. I had the same problem, and it was because I did not put the serverURL into my index.js file (documentation was incomplete at that moment). So, it still tried to communicate with https://api.parse.com that returned this.

This is how it should look with the serverURL option.

...
// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/dev',
  cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
  appId: 'myAppId',
  masterKey: '', //Add your master key here. Keep it secret!
  fileKey: 'optionalFileKey',
  serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed
});
...

@maurosoft1973
Copy link
Author

Hi Kira2!
thanks for your suggestion, but also adding the parameter serverURL the problem remains.

The configuration is identical (windows and linux)

@maurosoft1973
Copy link
Author

@simonbengtsson i dont'use the https://api.parse.com/1 as default serverURL, please
view configuration in previous comment, it is set correctly.
the problem it occurs only on debian enviroment, the same configuration on windows platform not generate error.

why?

@simonbengtsson
Copy link
Contributor

I mainly referenced because of @maurosoft1973 comment.

One way to debug this is to systematically follow the request. I would first add a console.log(method, url, data, headers); the first thing in node_modules/parse/lib/node/RESTController.js::ajax() (currently line 80). Then check those variables to see if they are as expected. If they are things gets interesting. If the log message is not printed you can check if the error is thrown in any of those places in Parse Server.

  • node_modules/parse-server/lib/schemas.js line 89
  • node_modules/parse-server/lib/middlewares.js currently line 169
  • node_modules/parse-server/lib/global_config.js currently line 31

Let me know your findings.

@maurosoft1973
Copy link
Author

@simonbengtsson i resolve problem, thanks!

in the linux enviroment, the restAPIKey has a value. remove, works.

this is my configuration

var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
cloud: '/cloud/main.js',
appId: '',
masterKey: '',
serverURL: 'http://localhost:' + port + '/parse',
push: {
android: {
senderId: '',
apiKey: ''
}
}
});

only appId ed masterKey is required ...

@simonbengtsson
Copy link
Contributor

I'm glad! Out of curiosity, how did the rest key only end up in debian? Environment variable?

@maurosoft1973
Copy link
Author

no enviroment variable, the paste rest Key accidentally in my configuration and I was convinced of the contrary!

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

3 participants