0

I searched a lot about how to use the instagram_graph_user_profile permission in Java but I can't find anything about it.

This is my code:

private void init_instagram() {
        FacebookSdk.setApplicationId(getString(R.string.facebook_app_id));
        FacebookSdk.sdkInitialize(this.getApplicationContext());
        if (BuildConfig.DEBUG) {
            FacebookSdk.setIsDebugEnabled(true);
            FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
        }
        callbackManager = CallbackManager.Factory.create();
        LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), (object, response) -> {
                    if (object != null) {
                        Log.e(TAG, object.toString());
                    } else {
                        Log.e(TAG, "null");
                    }
                });
                Bundle parameters = new Bundle();
                parameters.putString("fields", "instagram_graph_user_profile");//instagram_graph_user_profile
                request.setParameters(parameters);
                request.executeAsync();
            }

            @Override
            public void onCancel() {
                Log.e(TAG, "onCancel");
            }

            @Override
            public void onError(FacebookException exception) {
                Log.e(TAG, exception.toString());
            }
        });
    }

When I press the button:

connectInstagram.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LoginManager.getInstance().logInWithReadPermissions(MyProfileActivity.this,
                        Arrays.asList("instagram_graph_user_profile"));
            }
        });

It returns this error message:

Unsupported get request. Object with ID '2674********80' does not exist, cannot be loaded due to missing permissions, or does not support this operation

and redirect to a facebook page with message "Sorry, something went wrong. We are working on It and we'll get it fixed as soon as can."

or give me this error in console log:

E/GraphResponse: {HttpStatus: 400, errorCode: 104, subErrorCode: -1, errorType: OAuthException, errorMessage: An access token is required to request this resource.}

aghiad odeh
  • 39
  • 1
  • 8

1 Answers1

0

I searched a lot about how to use the instagram_graph_user_profile permission in Java but I can't find anything about it.

This is my code:

private void init_instagram() {
        FacebookSdk.setApplicationId(getString(R.string.facebook_app_id));
        FacebookSdk.sdkInitialize(this.getApplicationContext());
        if (BuildConfig.DEBUG) {
            FacebookSdk.setIsDebugEnabled(true);
            FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
        }
        callbackManager = CallbackManager.Factory.create();
        LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(), (object, response) -> {
                    if (object != null) {
                        Log.e(TAG, object.toString());
                    } else {
                        Log.e(TAG, "null");
                    }
                });
                Bundle parameters = new Bundle();
                parameters.putString("fields", "instagram_graph_user_profile");//instagram_graph_user_profile
                request.setParameters(parameters);
                request.executeAsync();
            }

            @Override
            public void onCancel() {
                Log.e(TAG, "onCancel");
            }

            @Override
            public void onError(FacebookException exception) {
                Log.e(TAG, exception.toString());
            }
        });
    }

When I press the button:

connectInstagram.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LoginManager.getInstance().logInWithReadPermissions(MyProfileActivity.this,
                        Arrays.asList("instagram_graph_user_profile"));
            }
        });

It returns this error message:

Unsupported get request. Object with ID '2674********80' does not exist, cannot be loaded due to missing permissions, or does not support this operation

and redirect to a facebook page with message "Sorry, something went wrong. We are working on It and we'll get it fixed as soon as can."

or give me this error in console log:

E/GraphResponse: {HttpStatus: 400, errorCode: 104, subErrorCode: -1, errorType: OAuthException, errorMessage: An access token is required to request this resource.}

aghiad odeh
  • 39
  • 1
  • 8
  • I got the same thing! Posted a question about it here https://stackoverflow.com/questions/65590113/is-refreshing-long-lived-access-token-endpoint-working-in-2021 – Akash Kundu Jan 09 '21 at 17:37