0

I created a role admin and user with that role.
In parse data browser I added admin role in security section read & write
Public can only read data.
Via curl I am trying to create new user:

curl -X POST \
  -H "X-Parse-Application-Id: ???" \
  -H "X-Parse-REST-API-Key: ???" \
  -H "X-Parse-Revocable-Session: 1" \
  -H "Content-Type: application/json" \
  -d '{"username":"somename","password":"xxxyyyyuuu"}' \
  --data-urlencode 'username=superuser' \
  --data-urlencode 'password=???????' \
  https://api.parse.com/1/users

I am getting:

{"error":"unauthorized"}

What am I missing in order to create user in user table?

1 Answer 1

2

It seems you might be using class level security settings, in which case your error could just be that you aren't passing the current user details correctly. You need to get the current user session token and pass it with -H "X-Parse-Session-Token: instead of trying to pass the details with --data-urlencode.


For the ACL, that applies to already created objects being editable, not to the ability to create new objects. So it has no bearing on the rest of the question. It isn't clear where you've set this ACL, but it would seem to be limiting access to an existing user that exists.

What you're doing is signing up a new user. For that you shouldn't be using --data-urlencode because you're POSTing. It appears that you're trying to do that to authenticate as one user while creating another user, but you can't. One user would need to be logged in already so you have a session token and then you would use -H "X-Parse-Session-Token: to pass it with the request.

So it seems your goal is to limit user creation to users in a specific role. To do that you should create your own function in cloud code, send the token for the currently logged in user, which is used in the cloud code to get the user and check they are a member of the role. Also send the new user username and password so once the verification is complete you can signup the new user (and return the user details).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.