0

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.

Omar Shawky
  • 1,242
  • 1
  • 12
  • 25
  • Documentation says `profile_pic` is the _"The profile picture URL of the Messenger user"_ - so likely that is connected with a page. For the user's normal profile picture, you should request `picture`. – CBroe Sep 20 '21 at 06:34
  • oh yes picture worked but the returned picture is of width and height 50X50, isn't there a way to enlarge it ? – Omar Shawky Sep 20 '21 at 10:27
  • 1
    https://stackoverflow.com/q/10650730/1427878 – CBroe Sep 20 '21 at 10:29

0 Answers0