Login Error: There is an error in logging you into this application. Please try again later

后端 未结 17 2774
野的像风
野的像风 2020-11-29 18:52

I am getting this error. When I try to sign in with facebook to my app. When I first time authentication it will correctly working. After I unistalled my application and now

17条回答
  •  执念已碎
    2020-11-29 18:59

    This problem occurs because you've already authenticated the app via Facebook and your code may contain Authenticate every time Facebook (Find and Remove that).

    Follow these steps:

    1. Go to Facebook settings.

    2. Remove your app.

    3. Make sure you've added Facebook Login in Facebook developer page and you've enabled Client OAuth Login.

    4. Go to your code and override the callback method:

      @Override
      public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          mFacebookCallbackManager.onActivityResult(requestCode, resultCode, data);
          if (resultCode == RESULT_OK) {
              Intent secondActivityIntent = new Intent(this, RedirectActivity.class);
              startActivity(secondActivityIntent);
          }
      }
      
    5. In the Oncreate method, call the AccessToken:

      accessTokenTracker = new AccessTokenTracker() {
          @Override
          protected void onCurrentAccessTokenChanged(
                  AccessToken oldAccessToken,
                  AccessToken currentAccessToken) {
              // Set the access token using
              // currentAccessToken when it's loaded or set.
          }
      };
      
      // If the access token is available already assign it.
      accessToken = AccessToken.getCurrentAccessToken();
      
      if (accessToken != null && !accessToken.isExpired())
      {
          GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
              @Override
              public void onCompleted(JSONObject object, GraphResponse response) {
                  if(null != object) {
                      try
                      {
                          Intent i = new Intent(MainActivity.this, Feedback.class);
                          startActivity(i);
                          String email = object.getString("email");
                          String birthday = object.getString("birthday");
      
                      }
                      catch (Exception ex)
                      {
                          Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_SHORT).show();
                      }
                  } else {
                      // call your authentication process
      
                  }
              }
          });
          Bundle parameters = new Bundle();
          parameters.putString("fields", "id,name,birthday,link");
          request.setParameters(parameters);
          request.executeAsync();
      }
      

提交回复
热议问题