Problem/Motivation

url structure to refresh long live tokens is not longer working, it seems that instagram has changed the url shape of this specific endpoint to:

GET https://graph.instagram.com/refresh_access_token
?grant_type=ig_refresh_token
&access_token={long-lived-access-token}

currently I see that this module uses an instagram wrapper https://github.com/espresso-dev/instagram-basic-display-php that has been inactive for quite some time and might be the source of the problem since the token refresh method comes from one of its classes:
EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay as well as some other methods to validate if a token refresh is actually needed.

Steps to reproduce

  • install the module
  • create an instagram simple app consumer
  • generate token
  • fill data in social feed module for instagram and save
  • wait for token expiration (it wont be renewed)

Proposed resolution

I'm not an expert in php or drupal module development, but I think that implementing other wrapper for instagram since espresso-dev seems to have abandonned the instagram-basic-display-php project

Issue fork socialfeed-3465324

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

je34429 created an issue. See original summary.

jayesh_vijay made their first commit to this issue’s fork.

jayesh_vijay’s picture

Hello I am working on this Issue

jayesh_vijay changed the visibility of the branch 3465324--token-refresh to hidden.

jayesh_vijay changed the visibility of the branch 3465324--token-refresh to active.

cesarcasg’s picture

Is there any progress on this one ?

m_hobby’s picture

Hi @Jayesh_Vijay,
I am also running into this issue with credentials expiring due to the change in the fetch URL structure.
I'm keen to get this resolved, and am happy to test any changes you made?
I've checked through the branch 3465324--token-refresh but can't see any commits relating to the access token.
Are you still looking at solving this?

hemangi.gokhale’s picture

Version: 2.0.x-dev » 3.0.x-dev
Assigned: Unassigned » hemangi.gokhale

First I thought of recommending version 3.x, but it turns out that version has the same problem!!

It looks like the third-party library we're using (espresso-dev/instagram-basic-display-php) has become inactive and is still relying on outdated Instagram API endpoints. After digging into it, it seems Instagram changed the structure of their token-refresh endpoint, so the library's refreshToken() method is hitting the wrong URL — which is why the token refresh keeps failing.

I'm going to look into creating a new InstagramApiService that makes direct HTTP requests to Instagram's current endpoints using Drupal's built-in Guzzle client.

  • hemangi.gokhale committed 4860be35 on 3.0.x
    Issue #3465324: Replace Instagram Basic Display with custom API service...
hemangi.gokhale’s picture

Assigned: hemangi.gokhale » Unassigned
Status: Active » Fixed

Alright, I've gone ahead and fixed the issue. Please give it a try and let me know if everything works on your end. Once someone confirms, I'll tag this as a release.

Also, a heads-up on some important updates: I've added notes about the Instagram API migration and updated the setup instructions. As of December 4, 2024, a Professional Instagram account (Business or Creator) is now required. Personal accounts are no longer supported. You can read more about this change here: https://developers.facebook.com/blog/post/2024/09/04/update-on-instagram...

Thanks everyone for spotting this issue and sharing your valuable updates!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

m_hobby’s picture

Hi @hemangi.gokhale
Thanks for all your work here.
I have reviewed the required documentation steps for the new account requirements, they are comprehensive.
Additionally I have tested the new retrieval mechanism for Instagram, and have not had any issues with the long-lived access token.
I think this is ready to be tagged as a release.
Thanks again.

hemangi.gokhale’s picture

@m_hobby Thanks for the feedback, really appreciate it! I'll tag a beta release today based on 3.0.x. If you have a moment, could you also try out 4.0.x with the same API and let me know how it goes? In the meantime, I'm working on adding proper test cases so we don't have to rely on manual testing. The only tricky part is that the API signatures keep evolving every year (sometimes even each quarter), which makes maintaining the tests a bit tedious.