So lately I've been trying to use Facebook's Graph Api and was trying to get some of user's data like email, profile picture, id and name as a start, but however I try to use a newMeRequest the response gives me an error that it wants a Page Access Token.
why would a newMeRequest need Page Access Token for !?, am I missing a permission to read my user data ?
- my code
String userId = Profile.getCurrentProfile().getId();
Bundle parameters = new Bundle();
parameters.putString("fields", "email,name,profile_pic,id");
GraphRequest request = GraphRequest.newMeRequest(
AccessToken.getCurrentAccessToken(), (jsonObj, response) -> {
if (response.getError() != null) {
Log.e("User err", response.getError().toString());
} else {
Log.e("User Json :", response.getJSONObject().toString());
UserEntity userEntity;
try {
userEntity = new UserEntity(jsonObj.getString("email"), jsonObj.getString("id"));
userEntity.setUsername(jsonObj.getString("name"));
userEntity.setUserPhotoUri(jsonObj.getString("profile_pic"));
loggedUser.setValue(userEntity);
insertUserEntity(userEntity);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
);
request.setParameters(parameters);
request.executeAsync();
- the error I'm getting + the log I'm printing
E/GraphResponse: {HttpStatus: 403, errorCode: 210, subErrorCode: -1, errorType: OAuthException, errorMessage: (#210) This call requires a Page access token.}
E/User err: {HttpStatus: 403, errorCode: 210, subErrorCode: -1, errorType: OAuthException, errorMessage: (#210) This call requires a Page access token.}
- permissions I've requested when user logs in :
{"public_profile", "email", "pages_manage_posts", "pages_read_engagement", "pages_show_list"}
Update :
It appears that the profile_pic
is the one causing this, so how do I request that field, from the documentation I don't see any permission specifications I need to get this field.