0
votes

I am working on Instagram api. I am getting problem with getting likes and comments of a public post in Instagram as it requires access token . As we can see from the Documentation is:

https://api.instagram.com/v1/media/{media-id}/likes?access_token=ACCESS-TOKEN

I could use a third party app to generate Instagram access token and save it to my database but the problem is access token can expire any time or once we change the password so I needed a life long token like as Facebook and twitter provides APP access token or Bearer Token to post of get on behalf of app which could be generated using APP Secret and Client Token. Or Please let me know if there's any ways to get Instagram public post likes and comments using Id.

Thanks in Advance.

1

1 Answers

0
votes

There are no life long tokens by design. You'll have to implement logic to refresh a token when it expires. There is no way around this, you have to use an access token and you have to deal with the fact that tokens expire. It's on you, as the developer, to implement logic. From the documentation:

Access tokens may expire at any time in the future.

The solution you're looking for does not exist. It's so easy to implement a refresh, just look for an error or type OAuthAccessTokenException then rerun your auth flow.