CHAYAN CHAKRABORTY
CHAYAN CHAKRABORTY

Reputation: 33

"Cannot save a ParseUser that is not authenticated"

I am trying to save data in authData field android, But I am getting exception: Cannot save a ParseUser that is not authenticated" after only reading the user

ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereEqualTo("username", email);
    query.findInBackground(new FindCallback<ParseUser>() {
        @SuppressWarnings("deprecation")
        public void done(List<ParseUser> scoreList, ParseException e) {
            if (e == null) {
                if(scoreList.size()>0){
                    facebook_user = (ParseUser) scoreList.get(0);
                    facebook_user.isAuthenticated()
                    JSONObject obj = new JSONObject();
                    try {
                        obj.put("name", "xyz");
                    } catch (JSONException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    facebook_user.put("authdata", obj);
                    facebook_user.saveInBackground(new SaveCallback() {
                        @Override
                        public void done(ParseException e) {
                        // exception in this section //
                        //Cannot save a ParseUser that is not authenticated"                 after only reading the user//
                        });

                }else{

                }
            } else {
                Log.d("score", "Error: " + e.getMessage());
            }
        }
    });

Upvotes: 3

Views: 640

Answers (1)

liampronan
liampronan

Reputation: 588

It looks like you are attempting to modify that user with the .put() before saving:

facebook_user.put("authdata", obj);
facebook_user.saveInBackground(new SaveCallback() {
  @Override
  public void done(ParseException e) {
    // exception in this section //

 });

If you want to change a user, you need to be logged in as the user, execute the change on Cloud Code using the masterKey, or change the user objects' ACL. Here's a SO post with a bit more info.

Let me know if you have any more questions.

Upvotes: 2

Related Questions