Search code examples
facebook-graph-apiinstagram-apiinstagram-graph-api

Refresh long-lived token via Instagram graph api


I have long-lived token of user on back-end and successfully getting different information from graph-api endpoints.

Now I am trying to refresh these valid, unexpired tokens on my side periodically and following Refresh Access Token documentation, but getting an error with 400 status code every time:

My request:

curl -X GET \
  'https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&&access_token={my_token}'

Response:

Sorry, this content isn't available right now

To make sure that token was valid, checked it via Access Token Debugger tool and it seems that my token is valid for next 3 months.

I found that several other engineers having the same problem but was not able to find any way out or the reason of this issue.

Is there any solution for it?


Solution

  • I have found an answer on my question and since I already see one person in comment, for whom my answer will be useful, going to post it here.

    In order to refresh valid token, we can use https://graph.facebook.com/oauth/access_token endpoint. So the request with params will be like this:

    https://graph.facebook.com/oauth/access_token?
    grant_type=fb_exchange_token
    &client_id={client-id}
    &client_secret={client_secret}
    &exchange_token={old_token}
    

    Also, one more note - if I remember correctly, even old token will keep valid until its ttl don't expires.