com.parse.ParseRequest $ ParseRequestException:Back4App的未授权错误(Parse)

时间:2017-02-15 18:14:28

标签: android parse-platform back4app

我首先在我的应用程序中使用Parse和AWS托管,但后来当Parse关闭他们的服务时我转移到了back4app。我的登录和注册曾经与之前的Parse项目一起正常工作,但现在每当我使用我的back4app项目登录或注册时,我都会收到错误 com.parse.ParseRequest $ ParseRequestException:未经授权。我尝试过使用Client Key和Master Key,但它们似乎根本不起作用。

这是我的注册码:

public void clickSignup(View view) {


    ParseUser.logOut();

    loader = (ProgressBar) findViewById(R.id.loadingBar);

    loader.setVisibility(View.VISIBLE);

    ParseQuery checkAvailability = ParseUser.getQuery();

    textUser = (EditText) findViewById(R.id.textUser);
    textPass = (EditText) findViewById(R.id.textPass);

    if (textUser.getText().toString().isEmpty() || textPass.getText().toString().isEmpty()) {

        loader.setVisibility(View.INVISIBLE);


        Toaster("Enter a valid username/password");



    } else if (textUser.getText().length() < 4){

        Toaster("Username must have four or more characters");

        loader.setVisibility(View.INVISIBLE);



    } else if (textPass.getText().length() < 6) {

        Toaster("Password mush have atleast six or more characters");

        loader.setVisibility(View.INVISIBLE);



    }else{

        String user =  textUser.getText().toString();

        Log.i("user", user);

        checkAvailability.whereEqualTo("username" , user);

        checkAvailability.findInBackground(new FindCallback<ParseUser>() {
            @Override
            public void done(List<ParseUser> objects, ParseException e) {

                if (e == null && objects.size() == 1){

                    loader.setVisibility(View.INVISIBLE);

                    Toaster("This username already exists");

                } else if (e == null && objects.size() != 1){

                    loader.setVisibility(View.INVISIBLE);

                    ParseUser newUser = new ParseUser();

                    newUser.setUsername(textUser.getText().toString());
                    newUser.setPassword(textPass.getText().toString());

                    newUser.signUpInBackground(new SignUpCallback() {
                        @Override
                        public void done(ParseException e) {

                            Log.i("S", "Seucbbkw");
                            Log.i("e", e.toString());

                            if (e == null){

                                Intent intent = new Intent(getApplicationContext(), LoggedIn.class);
                                intent.putExtra("Username",textUser.getText().toString() );
                                startActivity(intent);

                                Toaster("Signup Successful");

                            }


                        }
                    });


                } else {

                    Log.i("Objects", e.toString());

                }



            }
        });


    }

}

这是我的登录代码:

public void clickSignin(View view){

    ParseUser.logOut();

    textUser = (EditText) findViewById(R.id.textUser);
    textPass = (EditText) findViewById(R.id.textPass);
    loader.setVisibility(View.VISIBLE);


    if (textUser.getText().toString().isEmpty() || textPass.getText().toString().isEmpty()) {

        loader.setVisibility(View.INVISIBLE);


        Toaster("Enter a valid username/password");

    } else {

        final ParseQuery logInner = ParseUser.getQuery();

        logInner.whereEqualTo("username", textUser.getText().toString());

        ParseUser.logInInBackground(textUser.getText().toString(), textPass.getText().toString(), new LogInCallback() {
            @Override
            public void done(ParseUser user, ParseException e) {
                if (e == null) {

                    Intent intent = new Intent(getApplicationContext(), LoggedIn.class);
                    intent.putExtra("Username",textUser.getText().toString() );

                    startActivity(intent);



                    Toaster("Login Successful");

                    loader.setVisibility(View.INVISIBLE);

                } else {

                    Toaster("Invalid username or password");

                    Log.i("Error", e.toString());

                    loader.setVisibility(View.INVISIBLE);

                }
            }
        });
    }
}

1 个答案:

答案 0 :(得分:0)

(仅供测试)我建议您也使用appID连接Back4App!例如下面的代码:

<resources>

<string name="back4app_server_url">https://parseapi.back4app.com/</string>

<!-- Change the following strings as required -->
<string name="back4app_app_id">PASTE_YOUR_APPLICATION_ID_HERE</string>
<string name="back4app_client_key">PASTE_YOUR_CLIENT_KEY_HERE</string>
<string name="back4app_master_key">PASTE_YOUR_MASTER_KEY_HERE</string>
<string name="app_name">QuickstartExampleApp</string>