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
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:
Go to Facebook settings.
Remove your app.
Make sure you've added Facebook Login in Facebook developer page and you've enabled Client OAuth Login.
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);
}
}
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();
}