Graph API v2.3 , Cannot pass a read permission (re

2019-07-22 18:04发布

I'm trying to add additional permission to access friends list in my Android App , there are many resources about old API graph but could not find anything for new API , so I tried to add new permission to array but it didn't work and I got above error.

public void getProfileInformation()
{
    AccessToken token = AccessToken.getCurrentAccessToken();
    LoginManager.getInstance().logInWithPublishPermissions(LoginActivity.this, Arrays.asList(new String[]{"email", "publish_actions", "user_birthday", "user_hometown","read_custom_friendlists"}));

    final GraphRequest request = GraphRequest.newMeRequest(token, new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(JSONObject object, GraphResponse response) {

            try {
                Log.d("Firstname", object.getString("id"));
            } catch (JSONException e) {
                e.printStackTrace();
            }
            Log.d("Response Friend List", response.toString());

        }
    });
final Bundle parameters = new Bundle();
    parameters.putString("fields", "id, email, picture, birthday");
    parameters.putString("user", "100006601683765");

    GraphRequestAsyncTask graphRequest = new GraphRequest( AccessToken.getCurrentAccessToken(),"/{user-id}/", null , HttpMethod.GET ,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
                    parameters.putString("fields", "id, email, picture, birthday");
                    parameters.putString("user", "100006601683765");
                    request.setParameters(parameters);
                    //request.getParameters();
                    request.executeAsync();

                    Log.d("Yasser List",request.getGraphPath());
                }
            }
    ).executeAsync();
}

1条回答
仙女界的扛把子
2楼-- · 2019-07-22 18:15

Graph API v2.3 , Cannot pass a read permission (read_custom_friendlists) to a request for publish authorization

This error means that you cannot pass these permission in

logInWithPublishPermissions

you have use

LoginManager.getInstance().logInWithReadPermissions(instance, Arrays.asList("public_profile","user_friends","email"));

NOT This

LoginManager.getInstance().logInWithPublishPermissions(LoginActivity.this, Arrays.asList(new String[]{"email", "publish_actions", "user_birthday", "user_hometown","read_custom_friendlists"}));
查看更多
登录 后发表回答