Get/refresh access_token for MY OWN Instagram account

Viewed 923

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.

1 Answers
Related