1
        Parse.initialize(ApiKeys.appId, ApiKeys.jsKey, ApiKeys.masterKey);
        function submit(){
            var GameScore = Parse.Object.extend("GameScore");
            var gameScore = new GameScore();

            gameScore.save({
              score: 1337,
              playerName: "Sean Plott",
              cheatMode: false
            }, {
              success: function(gameScore) {
                // The object was saved successfully.
                debug_log("score success");
              },
              error: function(gameScore, error) {
                // The save failed.
                // error is a Parse.Error with an error code and message.
                debug_log("score error");
              }
            });
       }

I am sure that I have already config the keys. But I still cannot save, everytime, when I submit, it give me back error.

I use back{4}app instead of parse, is there something important was ignored by me?

Thanks in advance.

tim
  • 1,454
  • 1
  • 25
  • 45
  • 1
    read the error, it will tel you what is wrong :-), I think your initialize is also wrong, MasterKey should be stored only in the server and never send via Network...with masterkey you can delete your app... – Mazel Tov May 11 '16 at 10:39
  • Oh, finally I fixed it. About the master key, it seemed that in back4app'doc, initialize also has the masterkey parameter. But it seemed work too without master key. Do you know why? – tim May 11 '16 at 22:51
  • I dont know back4app, but MasterKey should be hidden as mush as possible, you shouldnt put it in third party SW or show anyone... I know that sometimes it is required by some services, but you would just give them full access to your app... – Mazel Tov May 12 '16 at 11:56

2 Answers2

2

You should provide the error code and its message.

The code seems ok, check your keys and settings.

Check the error message

not authorized=> keys not matched.

something like you are without permission to XXX=> check the class level permission (CLP)

or you have the beforeSave on cloud code, check response.success() have been called.

ChunTingLin
  • 970
  • 5
  • 14
1

Add Parse.serverURL="back4app api URL" Solve the ptoblem.

tim
  • 1,454
  • 1
  • 25
  • 45