2017-02-15 5 views
2

처음에는 내 응용 프로그램에 대해 AWS 호스팅과 구문 분석을 사용했지만 나중에 구문 분석 서비스를 종료 할 때 back4app로 이동했습니다. 내 로그인 및 가입을 사용하여 이전 구문 분석 프로젝트에서 제대로 작동했지만 이전에 로그인하거나 가입 할 때마다 com.parse.ParseRequest $ ParseRequestException : unauthorized 오류가 나타납니다. 클라이언트 키와 마스터 키를 모두 사용해 보았지만 전혀 작동하지 않는 것 같습니다.

여기 내 가입 코드입니다 :

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); 

       } 
      } 
     }); 
    } 
} 

답변

0

난 당신이 Back4App에 연결하는 데 너무 APPID를 사용하는 것이 좋습니다! 아래의 예를 들어 코드 :

<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>