Description
Updated the parse-server to latest (v2.0.6).
Dropped the DB and created new blank db in Mongo.
From node cli, tried to sign up a new user as described here.
> var Parse = require('parse/node').Parse;
undefined
> Parse.serverURL = 'http://localhost:1337/parse'
'http://localhost:1337/parse'
> Parse.initialize('1', 'abcd');
undefined
> var u = new Parse.User();
undefined
> u.set('username', 'kg');
ParseUser { _objCount: 1, className: '_User' }
> u.set('password', 'kg')
ParseUser { _objCount: 1, className: '_User' }
> p = u.signUp();
ParsePromise {
_resolved: false,
_rejected: false,
_resolvedCallbacks: [],
_rejectedCallbacks: [] }
> p
ParsePromise {
_resolved: false,
_rejected: true,
_resolvedCallbacks: [],
_rejectedCallbacks: [],
_error: ParseError { code: 105, message: 'invalid key name: _ApplicationId' } }
So far, I've been using this same setup successfully till v2.0.4 of parse-server.
Creating the user object using REST API with curl works properly. Then, the same Node.js cli process is able to login the user successfully.
curl -vvvv \
-H "X-Parse-Application-Id: 1" \
-H "X-Parse-Master-Key: 1" \
-X POST \
-d '{"username": "kg", "password": "kg"}' \
'http://localhost:1337/parse/users'
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 1337 (#0)
> POST /parse/users HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:1337
> Accept: */*
> X-Parse-Application-Id: 1
> X-Parse-Master-Key: 1
> Content-Length: 36
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 36 out of 36 bytes
< HTTP/1.1 201 Created
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< Access-Control-Allow-Headers: *
< Location: http://localhost:1337/parse/users/wJykcCCKo4
< Content-Type: application/json
< Content-Length: 116
< Date: Thu, 04 Feb 2016 18:40:04 GMT
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
{"objectId":"wJykcCCKo4","createdAt":"2016-02-04T18:40:04.068Z","sessionToken":"r:f8d907efdf92900acfa67d550ce89a6c"}
login from node cli:
> p = Parse.User.logIn('kg', 'kg');
ParsePromise {
_resolved: false,
_rejected: false,
_resolvedCallbacks: [],
_rejectedCallbacks: [] }
> p
ParsePromise {
_resolved: true,
_rejected: false,
_resolvedCallbacks: [],
_rejectedCallbacks: [],
_result: [ ParseUser { _objCount: 3, className: '_User', id: 'wJykcCCKo4' } ] }
Funnily, the JS sdk does not send the app id and the keys in the HTTP headers (X-Parse-Application-Id, X-Parse-Javascript-Key, X-Parse-Master-Key etc.) like other SDKs - instead, it sends it as part of HTTP body (JSON).
I verified that at least android and .NET/Unity SDKs send the app id and keys via HTTP headers by going through the code on github.
I've not been able to understand the reason for it. Can anyone please explain why the JS sdk behaves differently?