Refresh long-lived token via Instagram Graph API
Learn how to automatically refresh long-lived access tokens using the Instagram Graph API. Refer to how the Long-Lived Access Tokens for more info.
Long-lived tokens are valid for 60 days and can be refreshed as long as they are at least 24 hours old but have not expired, and the app user has granted your app the
instagram_graph_user_profile
permission. Refreshed tokens are valid for 60 days from the date at which they are refreshed. Tokens that have not been refreshed in 60 days will expire and can no longer be refreshed.
Refer to Display instagram posts into SharePoint using Instagram Basic Display Independent Publisher Connector how to integrate Instagram Feed into SharePoint.
Pre-Requisites to refresh token
- Facebook Developer Account & App with Instagram Basic Display API or Graph API
- A valid long-lived Instagram Access unexpired Token
Generate the token from UI
In case of expired long-lived token, it can be generated from the UI at Facebook for developers. Follow these steps:
- Click on Apps.
- Select the app you are using.
- Click on Instagram Basic Display to expand.
- Click on Basic Display.
- Scroll down to the section User Token Generator.
- Click on Generate Token.
Power Automate
Step 1: Create a Custom Connector
Create a custom connector to call the Refresh Token
endpoint. Alternatively, you can wait for the PR Instagram Basic Display (Independent Publisher) : Add Refresh token endpoint to allow refresh of long lived token from instagram basic display to be merged, which will add the endpoint to the independent publisher connector for Instagram Basic Display.
Step 2: Create a Scheduled Flow
Create scheduled flow to run every 50 days or at least every 24 hours
Step 3: Add the Refresh Token Action
Add the Refresh Token
action from the custom connector to the flow. Alternatively, you can use the HTTP
action with the following details:
- Method: GET
- Uri : https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token={Lon-lived token}
Step 4: Test the Flow
Run the flow to ensure it works correctly.
The expires_in
is 5183653 in seconds which is roughly 60 days.
The generated token can be updated in the corresponding application, with this access token lasting 60 days. Note that the previous access token is still valid and extended for 60 days as well.