"error":"unauthorized" on debian 8.3.0
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
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
});
...
Hi Kira2! thanks for your suggestion, but also adding the parameter serverURL the problem remains.
The configuration is identical (windows and linux)
@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?
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.jsline 89node_modules/parse-server/lib/middlewares.jscurrently line 169node_modules/parse-server/lib/global_config.jscurrently line 31
Let me know your findings.
@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 ...
I'm glad! Out of curiosity, how did the rest key only end up in debian? Environment variable?
no enviroment variable, the paste rest Key accidentally in my configuration and I was convinced of the contrary!