companionstudio / instagram-token-agent

A service to keep your Instagram Basic Display API token fresh.
MIT License
133 stars 70 forks source link

Error from Instagram: The access_token provided is invalid. #20

Closed davidkessler-ch closed 4 years ago

davidkessler-ch commented 4 years ago

When trying to use the instafeed.js, I get the following error: "Error from Instagram: The access_token provided is invalid." I have created multiple tokens and entered them into my heroku app, but it just doesnt seem to work. Now I would think that this is because of an issue with my app setup in facebook, however, in my heroku app it does seem to load the last post from my instagram feed perfectly..

Screenshot 2020-08-01 at 08 21 45

here is my code: `

<script type="text/javascript">
    var userFeed = new Instafeed({
        accessToken: InstagramToken,
        limit: '9',
        sortBy: 'most-recent',
        resolution: 'low_resolution',
        template: '<div class="col-lg-4 instaimg ori-{{orientation}}"><a href="{{link}}" title="{{caption}}" target="_blank"><img src="{{image}}" alt="Bitte stellen Sie eine sichere Verbindung her!" class="img-fluid"/></a></div>'
    });
    userFeed.run();
</script>`

Facebook does tell me to verify my business, but I thought the app should also work like this since I have setup a tester..

Info:

benjamin-hull commented 4 years ago

Hi @bryant22 - like you said, the fact that you can see the post in the token agent screen means you must have a valid access token. Could you just confirm that you're using v2 of instafeed.js ? Some of those options you have - resolution, limit, etc. - aren't available in v2, which makes me wonder if you're using instafeed v1 still?

davidkessler-ch commented 4 years ago

Alright, I was able to fix it.

  1. limit now has to be given a number, not a string containing the number
  2. I foolishly loaded the script before the #instafeed was defined -.- (thats why scripts should always be loaded in the footer)
  3. resolution and sortBy had to be removed