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

Parse Server Unauthorized Error #127

Closed
conan311 opened this issue Feb 1, 2016 · 17 comments
Closed

Parse Server Unauthorized Error #127

conan311 opened this issue Feb 1, 2016 · 17 comments

Comments

@conan311
Copy link

conan311 commented Feb 1, 2016

Hi Guys,

I know we are all on the same boat as Parse lovers but especially I am now very devastated since I had zero knowledge about Node.js and MongoDB. I spent a couple of days studying a bit about them and now got some basic concepts. I have been trying to set up a Parse server and MongoDB locally first. I have installed them correctly (I believe) but when I run "npm start" to start Parse Server, I got the following messages. FYI I see mongod and mongo running without an issue.

DATABASE_URI not specified, falling back to localhost.
parse-server-example running on port 1337.

In browser, if I go to "localhost:1337/parse", it gives me the following error. (localhost:1337 is fine)

{"error":"unauthorized"}

And this is my API setup. I did provide databaseURI but don't know why it is complaining that it is not specified.

var api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
appId: 'xxx',
masterKey: 'yyy'
});

Not sure what I am missing or set up incorrectly. Please advice me.

@fraxool
Copy link

fraxool commented Feb 1, 2016

Hi,

The message you have {"error":"unauthorized"} is not an error when you check your server directly with your web browser by typing localhost:1337/parse. This URL is not meant to be used in a browser (without keys).

In my opinion, your configuration is good.
Did you try to send a request to your Parse server from your code (with the keys) and check the result from here ? If you still get the error message {"error":"unauthorized"}, it's because you didn't set up your keys correctly

@christianmarth
Copy link

If you've set a username and password for a separate parse user for the parse database you'll also need to set that in the databaseURI

"databaseURI": "mongodb://parseuser:password@localhost:27017/parse",

@conan311
Copy link
Author

conan311 commented Feb 1, 2016

Thanks guys..really really appreciate it! More questions here.

  1. According to index.js of parse-server express, isnt it supposed to do the following? I was expecting to see the message from console logs.

var port = process.env.PORT || 1337; app.listen(port, function() { console.log('parse-server-example running on port ' + port + '.'); });

  1. For databaseURI part, according to parse-server express, it is saying "You now have a database named "dev" that contains your Parse data". Does it mean after running Parse Server, the database and its collections and documents imported automatically from my app?
  2. I haven't set up any username and password for a separate parse user for the parse database. Still no idea why I got the following message when running the server.

DATABASE_URI not specified, falling back to localhost. parse-server-example running on port 1337.

@christianmarth
Copy link

Hi,

Have you run the migration tool already?

Maybe try doing a few cURL requests to localhost

curl -X GET \
  -H "X-Parse-Application-Id: YOUR_APP_ID" \
  -H "X-Parse-Master-Key: YOUR_APP_MASTER_KEY" \
  http://localhost:1337/parse/classes/_User

@gfosco
Copy link
Contributor

gfosco commented Feb 2, 2016

@conan311

Yes you should see that the server is running, when you run it... npm start. And you do, it's at the end of the message you posted.

If you have NO database, it will create one... but no, it will not automatically migrate from Parse, you have to do that through the UI on Parse.com, and you should not migrate to your localhost machine.

You're getting the 'falling back to localhost' message because you didn't set the DATABASE_URI environment variable, or pass in a connection string to the ParseServer initialization. Look at the guide for running on mongolab for an example.

@gfosco gfosco closed this as completed Feb 2, 2016
@conan311
Copy link
Author

conan311 commented Feb 2, 2016

After a few rounds of trials and failures, I finally got it working. Your answer did really help a lot to solve my curiosities. Due to my entry level knowledge to Nods.js & MongoDB, I had a few misunderstanding in how it works: (I know they sound dumb but just posting it to help any other newbies who would make similar mistakes in future)

  1. I didn't run mongod before running Parse Server.
  2. I didn't properly provide DATABASE_URI in `index.js'
  3. I didn't know '{"error":"unauthorized"}' displayed in the browser means it is working.
  4. I didn't know data will not be automatically imported from Parse. I thought the statement if you have no database, it will create one means it will migrate data automatically too.

Everything is crystal clear now. Thanks heaps lads!!
p.s: Just curious how it is going in regards to the development of Dashboard.

montymxb pushed a commit to montymxb/parse-server that referenced this issue Feb 14, 2016
Add anonymous user login and fix some bugs.
@narendraojha
Copy link

@ALL,
I have successfully set up parse server locally but I am having problem while executing query. The URL formed by the parse helper is:
http://localhost:1137/parse/1/classes/_User?where=%7B%22rowid%22%3A67%7D&limit=1

I am getting response as "false" in _request(...) method of parseClient class.

But when i send a hardcoded url as:
http://localhost:1137/parse/classes/_User
i get all the users.
can you please help me why am i getting a false response when i request the 1st url?

thanks

@jspenc72
Copy link

jspenc72 commented May 4, 2016

I am having the same problem as @narendraojha.

How do we configure the parse url helper to omit the '/1/'

Any help is greatly appreciated.

@narendraojha
Copy link

@jspenc72, the url issue has already been fixed in New Parse PHP SDK. I was using old version of sdk and after update issue is fixed.
Hope it will help you.

@jspenc72
Copy link

jspenc72 commented May 7, 2016

I'm using the Java script sdk in nodejs. Do you know if it's fixed there?

On May 6, 2016, at 8:16 PM, Narendra Raj Ojha notifications@github.com wrote:

@jspenc72, the url issue has already been fixed in New Parse PHP SDK. I was using old version of sdk and after update issue is fixed.
Hope it will help you.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@narendraojha
Copy link

No, I don't have any idea about java script sdk.

@jspenc72
Copy link

jspenc72 commented May 9, 2016

Ok thank you

On May 9, 2016, at 1:19 AM, Narendra Raj Ojha notifications@github.com wrote:

No, I don't have any idea about java script sdk.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@greggmojica
Copy link

Same issue. Any resolution?

@flovilmart
Copy link
Contributor

this issue has been closed for a while. Please reopen an issue filling the issue template

@jspenc72
Copy link

No, the project ended up getting cancelled so I never found a solution.

On Oct 25, 2016, at 7:32 PM, Gregg Mojica notifications@github.com wrote:

Same issue. Any resolution?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@mgonzaleza
Copy link

mgonzaleza commented Jan 24, 2017

@ALL I managed to get thorough the unauthorized issue, but now if I try to get back results from any of my collections using curl, I get an empty response. Any ideas? Thanks!

curl -X GET \ -H "X-Parse-Application-Id: xxxx" \ -H "X-Parse-Master-Key: yyyy" \ http://localhost:1337/parse/classes/Zip {"results":[]}%

@kherox
Copy link

kherox commented Sep 11, 2017

If you have this error , it about this url "http://localhost:1337/parse" it use for api call with some params. So if you use your browser to seed the request, params are missing. If you want to see the result go this. Thanks

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

9 participants