skip to Main Content

I make a request to find out the data about my user access token:

fetch("https://graph.facebook.com/v8.0/debug_token?input_token=" + access_token).then(function (response) {
   response.text().then(function (textII) {
       alert(textII);
   });
});

In this case, I take the accessToken value from auth Response after authorization to the application and Facebook:

{
    status: 'connected',
    authResponse: {
        accessToken: '{access-token}',
        expiresIn:'{unix-timestamp}',
        reauthorize_required_in:'{seconds-until-token-expires}',
        signedRequest:'{signed-parameter}',
        userID:'{user-id}'
    }
}

But I get an error:

{
   "error": {
      "message": "(#100) You must provide an app access token or a user access token that is an owner or developer of the app",
      "type": "OAuthException",
      "code": 100,
      "fbtrace_id": "AtpM_XaTOgH7YH-OXHdQCXj"
   }
}

The value of my variable access_token is not null (I checked), while this is sort of a user access token (the keyword "sort of"). So what’s wrong? Explain, please. If you need information about what I need it for, then I need it for this request:

for (var iio = 0; iio < posts_ids.length; iio++) {
fetch("https://graph.instagram.com/" + posts_ids[iio] + "?fields=id,media_type,media_url,owner,timestamp&access_token=" + access_token).then(function (response) {
      response.text().then(function (textII) {
          alert(textII);
      });
  });
}

Which throws an error:

{
   "error": {
      "message": "Invalid OAuth access token.",
      "type": "OAuthException",
      "code": 190,
      "fbtrace_id": "AD7BAPqUGdQGC6dyV9K_FFr"
   }
}

At the same time, in my previous requests, just starting with "https://graph.facebook.com/", and not "https://graph.instagram.com/", everything worked with the accessToken that I received after registration.
Help me please. I’m new to the Instagram API, so I can be pretty dumb.

5

Answers


  1. Please turn off the setting(Setting -> Advanced -> Application authentication), it works!

    Login or Signup to reply.
  2. @Denis Bredun , you would have to pass access_token field also as the URL param, so just update the url to –

    https://graph.facebook.com/v8.0/debug_token?input_token=<access_token>&access_token=<access_token>
    
    Login or Signup to reply.
  3. Try resetting your app secret. I was getting the same problem, and this fixed it.

    Login or Signup to reply.
    • I solved the error by changing the app secret to the correct one.

    Make sure you are using the proper app secret.

    Login or Signup to reply.
  4. For me, using the debug_token api requires the "page token" and the "app token" and then you call the api in the format :
    https://graph.facebook.com/v<version>/debug_token?input_token=<page_token>&access_token=<app_token>

    As per the facebook doc To get the app_token, you need the app id and app secret. And then you call https://graph.facebook.com/oauth/access_token?client_id={your-app-id}&client_secret={your-app-secret}&grant_type=client_credentials

    To get the page_token, this is done by first getting the user_token, then you convert the user_token into a long lived user token, and then you get the page token calling the api "/<page_id>?fields=access_token".
    Note that you will need the proper permissions on the user_token to do that, like "pages_read_engagement" otherwize you will get an error from the api trying to get the page token.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search