When I try to query facebook, I get the following exception: "An active access token must be used to query information about the current user."
This is the request:
AccessToken accessToken = AccessToken.getCurrentAccessToken();
GraphRequest request = GraphRequest.newMeRequest(
accessToken,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
FacebookRequestError responseError = response.getError();
if(responseError != null){
if(responseError.getCategory().equals(FacebookRequestError.Category.LOGIN_RECOVERABLE)){
LoginManager.getInstance().resolveError(MainActivity.this, response);
} else {
Toast.makeText(MainActivity.this, getString(R.string.facebookError), Toast.LENGTH_LONG).show();
Log.e(TAG, Helper.isFacebookLogin() + "");
return;
}
} else {
try {
Log.e(TAG + " newMeRequest id", object.getString("id"));
} catch (JSONException e) {
Log.e(TAG + " newMeRequest JSONerror", e.getMessage());
}
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,gender");
request.setParameters(parameters);
reques
t.executeAsync();
Helper.isFacebookLogin() is:
public static boolean isFacebookLogin(){
return accessToken != null && !accessToken.isExpired();
}
and returns true.
If it returns true, why do I get the error message?