superfive33
superfive33

Reputation: 1174

Get/refresh access_token for MY OWN Instagram account

I'm using the new Instagram Basic Display API.
I followed these steps to get an access_token: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

The problem is that the access_token expires very quickly (about one hour later) and I have to get a new authorization code from api.instagram.com, then exchange it for a new access_token. The authorization step has to be a manual step because I need to authenticate into Instagram with my account credentials (I open the URL in my browser: https://api.instagram.com/oauth/authorize?app_id={APP_ID}&redirect_uri={REDIRECT_URI}&scope=user_profile,user_media&response_type=code).

The exchange of the authorization code with an access_token can be done programmatically (with cURL).

curl -X POST \
                    https://api.instagram.com/oauth/access_token \
                    -F app_id={APP_ID} \
                    -F app_secret={APP_SECRET} \
                    -F grant_type=authorization_code \
                    -F redirect_uri={REDIRECT_URI} \
                    -F code={AUTH_CODE}

I just want to get the media of my own Instagram account. Is there a way to have access to my own data without the need to refresh my access_token every hour ?

I found that this endpoint was publicly readable: https://www.instagram.com/proquartet_cemc/?__a=1

If I cannot use the Basic Display API, I will parse the JSON returned by this endpoint. But it is not documented anywhere so it may be disabled at any time...

Thanks for your help.

Upvotes: 5

Views: 1169

Answers (1)

Juany
Juany

Reputation: 11

i have the same problem, but in new update (2019-12-06), instagram api add Long-Lived Access Tokens ( It is not the best solution, but these are valid for 60 days. Important: Long-lived tokens that have not been refreshed in 60 days will expire)

https://developers.facebook.com/docs/instagram-basic-display-api/changelog

Sorry for my english, it's not good.

Upvotes: 1

Related Questions