Skip to content

Parse query returns: Permission Denied for this Action Android #337

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

Closed
antonioallen opened this issue Feb 10, 2016 · 9 comments
Closed

Parse query returns: Permission Denied for this Action Android #337

antonioallen opened this issue Feb 10, 2016 · 9 comments

Comments

@antonioallen
Copy link

For some reason everytime I call a Parse Query I get denied. I was working on app last night and everything was fine. This morning I keep getting the error. I am using AWS to host and MongoDB. Also I'm working on Android. Any help would be great. This is my code:

`if (ParseUser.getCurrentUser() != null){
new Thread(new Runnable() {
@OverRide
public void run() {
Log.e(TAG, "Finding Users");

                ParseQuery<ParseUser> parseQuery = ParseUser.getQuery();
                parseQuery.whereNotEqualTo("objectId", ParseUser.getCurrentUser().getObjectId());
                parseQuery.findInBackground(new FindCallback<ParseUser>() {
                    @Override
                    public void done(List<ParseUser> users, ParseException e) {
                        if (e == null && users != null) {
                            mAdaper.clear();
                            userlist.clear();
                            swipeRefreshLayout.setRefreshing(false);
                            for (int i = 0; i < users.size(); i++) {
                                addUser(users.get(i));
                            }
                        } else {
                            swipeRefreshLayout.setRefreshing(false);
                            if (e != null) {
                                Log.e("ERROR FIND USERS", e.getMessage()+ " "+e.getLocalizedMessage()+ " "+e.getCode());
                            }
                        }
                    }
                });

            }
        }).start();
    }`

and this is my error:
02-10 10:23:55.948 31981-32158/com.antonioallen.app E/CommunityFragment: Finding Users 02-10 10:23:56.048 31981-31981/com.antonioallen.app E/ERROR FIND USERS: Permission denied for this action. Permission denied for this action. 101

@antonioallen antonioallen changed the title Parse query returns: Permission Denied for this Action Parse query returns: Permission Denied for this Action Android Feb 10, 2016
@antonioallen
Copy link
Author

Ok so I solved this. If you are using Mongo DB, and didn't migrate your data from parse, the classes in _SCHEMA may be missing the the proper permissions in class_permissions. Open the User Class (or any class you want to CRUD) in _SCHEMA and add the code below to it.
"_metadata": { "class_permissions": { "get": { "*": true }, "find": { "*": true }, "update": { "*": true }, "create": { "*": true }, "delete": { "*": true }, "addField": { "*": true }, "readUserFields": [], "writeUserFields": [] } },

Adjust the comma at the end as needed. Hope this helps!

@tran-huy-phuc
Copy link

Hey @aaadesignstudios
I changed the _SCHEMA but I still get the error: Permission Denied for this Action Android (101).
Do you have any idea?

@drew-gross
Copy link
Contributor

@aaadesignstudios this actually sounds like a bug, so I'm going to re-open this. Can you tell what class you saw this issue for, how you created that class (dashboard, client, etc...) and if possibly, what the contents of the _SCHEMA collection were before you modified it?

@drew-gross drew-gross reopened this Mar 25, 2016
@tran-huy-phuc
Copy link

@aaadesignstudios
I had to delete all data in _SCHEMA to make it work again. But after that, the issue comes back, so I have to delete again, again and again.
Do you have any idea?

@drew-gross
Copy link
Contributor

Before deleting, can you copy your _SCHEMA collection and paste it here, and also describe how you are creating the schema?

@tran-huy-phuc
Copy link

The _schema collection is created automatically when migrating from Parse or when user logged in.
@techmohib011 Can you copy your _schema collection here?

@ghost
Copy link

ghost commented Mar 28, 2016

This is the schema collection

{
"_id": "_Session",
"sessionToken": "string",
"user": "__User",
"createdWith": "object",
"restricted": "boolean",
"installationId": "string",
"expiresAt": "date"
}
{
"_id": "sObject",
"user_like_me": "array",
"user_matches": "array",
"ACL": "object",
"randomValue": "string",
"last_name": "string",
"user_seen": "array",
"name": "string",
"user_super_like": "array",
"user_super_like_me": "array",
"user_like": "array",
"user_dislike_me": "array",
"user_dislike": "array",
"first_name": "string",
"objectId": "string"
}
{
"_id": "_User",
"authData": "object",
"diet": "string",
"profession": "string",
"religious_belief": "string",
"income": "string",
"link": "string",
"locale": "string",
"age_range": "object",
"height": "string",
"pets": "string",
"intent": "array",
"smoke": "string",
"timezone": "string",
"user_about_me": "string",
"kink": "string",
"age": "number",
"relationship_status": "string",
"verified": "boolean",
"facebook_id": "number",
"i_am_a": "string",
"sObject": "_sObject",
"education": "string",
"username1": "string",
"drink": "string",
"objectId": "string",
"userLocation": "geopoint",
"user_auth_id": "string"
}
{
"_id": "_Installation",
"user": "string",
"objectId": "string",
"appName": "string",
"appVersion": "string",
"deviceType": "string",
"appIdentifier": "string",
"installationId": "string",
"pushType": "string",
"timeZone": "string",
"localeIdentifier": "string",
"parseVersion": "string",
"deviceToken": "string"
}
{
"_id": "Search",
"lookingFor": "array",
"ACL": "map",
"newSearch": "boolean",
"minmax": "array",
"intent": "array",
"user": "*_User",
"reference": "string",
"religiousBelief": "array",
"objectId": "string",
"_metadata": {
"class_permissions": {
"get": {},
"find": {},
"update": {},
"create": {},
"delete": {},
"addField": {},
"readUserFields": [],
"writeUserFields": []
}
}
}

@drew-gross
Copy link
Contributor

I'm confused now, there are too many people in this thread with the slightly different issues, some oh whom have solved their issue and some of whom haven't. If you are still having problems, can you open a new issue with how you are creating your collection, how you are accessing it, and what it looks like in the database?

@mediaexpander
Copy link

Hi, is there a way to add those permissions automatically?

"metadata": { "class_permissions": { "get": { "": true }, "find": { "": true }, "update": { "": true }, "create": { "": true }, "delete": { "": true }, "addField": { "": true }, "readUserFields": [], "writeUserFields": [] } },_

I create an schema through the iOS SDK but they are not added (_SCHEMA class updated succesfully).

Thank you

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

4 participants