Parse-server: Basic Login via js api not working

Created on 24 Apr 2016  ·  85Comments  ·  Source: parse-community/parse-server

var user = new Parse.User();
user.set("username", "my name");
user.set("password", "my pass");
user.set("email", "[email protected]");

// other fields can be set just like with Parse.Object
user.set("phone", "415-392-0202");

user.signUp(null, {
success: function(user) {
// Hooray! Let them use the app now.
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert("Error: " + error.code + " " + error.message);
}
});

Get error 403

Most helpful comment

Thanks for this thoughtful response. But as you probably noticed, not only the login is not working for you but also all queries respond with an error. You also probably noticed that your iOS SDK is working correctly with your setup. So I doubt that the error is an issue with parse-server, but most likely an issue with the configuration / javascript SDK.

I'm not really sure what the error is, nor what the problem is. AFAIK, the VERBOSE flag should start spitting out logs and more precisely all request and response logs.

Yes verbose logging requires an environment variable, like express need an environment variable to enable DEBUG logging or the http module needs as well an environment variable to enable more logs.

Again, I can only encourage you to contribute, and if you haven't noticed, I'm not part of Facebook, but a guy like you, having clients relying on their parse instances to work and be transitioned.

All 85 comments

Can you provide logs by running parse-server with VERBOSE=1

I'm using the express server so I can get https. How exactly do I pass that to it?

just set an environment variable VERBOSE=1 before you start parse server. if you start with node server.js that would be VERBOSE=1 node server.js

`var fs = require('fs'),
https = require('https');
var ssl = {
key: fs.readFileSync('./', 'utf8'),
cert: fs.readFileSync('./', 'utf8'),
ca: [fs.readFileSync('./', 'utf8'),
fs.readFileSync('./', 'utf8')]
};
var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var databaseUri = ' ';

var port = process.env.PORT || 4337;
//var port = 443;
var api = new ParseServer({
databaseURI: databaseUri,
cloud: __dirname + '/cloud/main.js',
serverURL: 'aa',
appId: 'aa,
'javascriptKey':'aa',
restAPIKey: 'a',
clientKey:'a',
facebookAppIds :['a'],
masterKey: 'a'
});
var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = '/a';
app.use(mountPath, api);
app.use(express.static('public'));
// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
res.status(200).send('I dream of being a web site.');
});

app.listen(4338,function () { console.log('Server on port 4338'); });
https.createServer(ssl, app)
.listen(port, function() {
console.log('Server running on port ' + port + '.');
});`

I changed all my urls and keys to paste it in here. They are not actuall "a"

I need the server logs, when you're trying to do the login to identify the potential problem.

You mean the logs from the javascript call? Sure one sec

The logs the server is printing in the terminal/console when you run that.

Oh lol, I use the forever service. This ain't running in a console. One second, I will oblige.

There are no logs in the console.

Request URL:https://:4337/Parse/users Request Method:POST Status Code:403 Forbidden Remote Address: :4337 Response Headers view source Access-Control-Allow-Headers:* Access-Control-Allow-Methods:GET,PUT,POST,DELETE,OPTIONS Access-Control-Allow-Origin:* Connection:keep-alive Content-Length:24 Date:Sun, 24 Apr 2016 17:50:00 GMT X-Powered-By:Express Request Headers view source Accept:*/* Accept-Encoding:gzip, deflate Accept-Language:en-US,en;q=0.8 Connection:keep-alive Content-Length:239 Content-Type:text/plain DNT:1 Host::4337 Origin:https://:4337 Referer:https://:4337/signup.html User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36 Request Payload view source {username: "my name", password: "my pass", email: "[email protected]", phone: "415-392-0202",…} _ApplicationId : "a" _ClientVersion : "js1.6.14" _InstallationId : "bf757e4d-1ade-f921-030d-1192034d1356" email : "[email protected]" password : "my pass" phone : "415-392-0202" username : "my name"

Response is {"error":"unauthorized"}

However, our iphone app can accss/create users fine.

those are not the server logs when running with VERBOSE=1, I need the server logs, not the client logs

If that's an issue on the JS SDK so open the issue on the JS SDK repository

I understand, how do I start it with that parameter. Just node index.js VERBOSE=1

You have to understand I'm not a node programmer so the things you think are obvious aren't.

Where exactly is the js api? I'm using the one that used to be hosted on parsecdn. Is there another one?

https://github.com/ParsePlatform/Parse-SDK-JS/issues

Also did you set correctly serverURL in your SDK?

Yes, and I'm using that one, how do I turn on verbose mode? I don't think it's an sdk issue or there'd already be open issues.

It's posting to the correct url in the logs. It's not trying to go to parse.

you set VERBOSE=1 on your server, not on the client SDK

I know, where though? At what point in the index.js above? Or does parse-server module parse command line args?

this is an environment variable. so, just set that environment variable and restart your server. If you don't know how to set an environment variable, I believe stack overflow or google can help you

Oh I know how to linux like a pro.

I don't even know node and I set all of this up.

Well, I set up an issue here: https://github.com/ParsePlatform/Parse-SDK-JS/issues/262

You can probably mark this as closed. Is there a way to force parse-server to always log verbose to a file?

run with VERBOSE=1 and forward the stdout/stderr streams to your log files.

Fairly unprofessional.

Setting env variables isn't a good solution for logging. Please add a feature to set a verbose log file. Thanks anyway.

What do you mean? If you're using forever everything is in the forever docs right on the README.md

And PR's are welcome, I belive there is also a verbose option, that you can set to true, when you create a new ParseServer.

I turned the forever off to run it in the console. I removed the element. So there is a parse server option "verbose"?

So to be clear, since it hasn't added anymore logging or the error is with jssdk,

var api = new ParseServer({ databaseURI: databaseUri, verbose:true,

I'm not 100% sure if that flag enables the console logs, that's why you can enable the console logs by using VERBOSE=1 as an environment variable.

I did the env variable. Nothing additional came out of the console.

The error is 403 forbidden. Does that mean parse rejected the request ?

that mean the authentication failed. How did you do the environment variable?

[root@localhost ParseServer]#VERBOSE=1
[root@localhost ParseServer]# node index.js

▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░making app
Server on port 4338
Server running on port 4337.
`

that would be VERBOSE=1 node index.js
Also, that's a bad idea to run a server as root...

Parse JavaScript SDK v1.6.14

The forever service normally runs this as a separate user.

that would be VERBOSE= 1node index.js
^^ what are you saying ?

the command you should run should be :

VERBOSE=1 node index.js

that's not the same as:

# VERBOSE=1
# node index.js

Still no difference

Must be a javascript api issue. 1.6.14 ... Would it matter that I'm hosting the .js file and not on parsecdn?

I was trying to avoid having to set cross-domain stuff.

So I'm not sure what's wrong because that should start printing every requests/responses in the console.
That would mean your JS-SDK is not properly configured and is not going to your server.

going back to your logs you posted from the JS-SDK,

Request URL:https://:4337/Parse/users

For some reason that seem plain wrong...

well I removed the url...

I can pm you the site

[root@localhost ParseServer]# VERBOSE=1 node index.js
making app
Server on port 4338
Server running on port 4337.

well, that seems to be the issue... Did you double check your javascriptKey is valid? Also, because the server responds with 403, this is a SDK authentication issue.

Yes, the key and the appID match.

The error is odd:

ParseError {code: undefined, message: "unauthorized"}

I'm going to try removing the js key from index.js and just using the appid

Nope same problem. Even if I disable the jskey, clientkey, and restapikey.

what version of parse-server are you using? Any chance to get the logging working, otherwise it would mean that the requests don,t hit the proper server...

Whatever is the latest. This install is 2 weeks old. I ran npm update in the folder.

I tried with the masterkey. Same error.

Does other queries get logged when running your server with VERBOSE=1? That's what worries me about your setup as it seems that the client never reaches the proper server....

I can manually enter the url for the server mount in the browser and see nothing in the log

that doesn't make sense at all...

Welcome to the world of programming.

:)

why do you have 2 different port logged:

Server on port 4338
Server running on port 4337.

Your https server is listening on 4338 it seems and all your requests seem to go to 4337...

4338 is http (normal 80)
4337 is https (normally 443)

and if you do everything on HTTPS? would that change anything?

nothing changes no matter which port I select.

I disabled http for the purpose of testing now. Nothing changes.

I'm running centos btw, not ubuntu

Does any query make it through to your server?

yes, but they all return the same error message ParseError {code: undefined, message: "unauthorized"}

I'm initing with the appid and jskey

Parse.initialize("appid","jsserver");

Parse.serverURL = 'https://:4337/Parse'

is your mount path correct? your replaced it with /a in your config, did you pass serverURL to be from the proper form? http://localhost:1234/Parse ?

yes, like I said. I copied this from our working iphone app exactly.

My configuration has been tested and supports a full app.

SO that's an issue with the JS SDK most likely, that's still not expected that no logs are being triggered on the server. Do you confirm that running with VERBOSE=1, the calls from the iOS app are getting logged?

I can not change the IOS app server as it is in production.

This is the dev server to set up the js work.

However, like I said, it's an exact clone.

Could it be express ?

and the iOS apps pointing to the dev server? This don't seem to be an issue on parse-server as you got it working with other SDK's.

You're starting to see why env variables are what I called unprofessional. You gotta command line it or pass it as a server option otherwise you'll run into this situation where an oddball config'd server doesn't play nice.

env variable are better than updating your source code to enable verbose logging...

no, lol. It should be a simple flag either way. Relying on OS specific things like env variables is very unprofessional.

this is an open source project, you're welcome to contribute to make it fit your needs.

Thanks for the help!

Please don't try that excuse. I've used parse for my clients for years. I'm having to do countless hours of free work now because of this "transition." We're all doing our part.

Check your ego at the door, mate. I'm just here to get this stuff out the door not compare dicks.

Thanks for this thoughtful response. But as you probably noticed, not only the login is not working for you but also all queries respond with an error. You also probably noticed that your iOS SDK is working correctly with your setup. So I doubt that the error is an issue with parse-server, but most likely an issue with the configuration / javascript SDK.

I'm not really sure what the error is, nor what the problem is. AFAIK, the VERBOSE flag should start spitting out logs and more precisely all request and response logs.

Yes verbose logging requires an environment variable, like express need an environment variable to enable DEBUG logging or the http module needs as well an environment variable to enable more logs.

Again, I can only encourage you to contribute, and if you haven't noticed, I'm not part of Facebook, but a guy like you, having clients relying on their parse instances to work and be transitioned.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ViolentCrumble picture ViolentCrumble  ·  3Comments

carjo422 picture carjo422  ·  3Comments

ugo-geronimo picture ugo-geronimo  ·  3Comments

kilabyte picture kilabyte  ·  4Comments

ShawnBaek picture ShawnBaek  ·  4Comments