I'm trying to use instagram api to show #'s on my webpage but i need to generate user token for instagram tester. I followed the documentatio (created an application, use my page url, sent invitation for instagram tester and accepted it) but when i click on generate token for instagram tester it displays a pop-up window to allow permissions, then it shows nothing. I tried with another account, creating a different application but the result is the same.
CodePudding user response:
Facebook token generator seems to be broken, but you can generate your own long-lived access token following OAuth2 workflow (replace {}
placeholders with your own values):
- In your browser, go to:
https://api.instagram.com/oauth/authorize?client_id={your-client-id}&client_secret={your-client-secret}&redirect_uri={a-valid-redirect-url}&scope=user_profile,user_media&response_type=code
- Login to your Instagram account and accept your application to access your data
- You should be redirected to
{a-valid-redirect-url}?code=xxxxx#_
then copy to {code} query string value without the#_
at the end - Use Postman to execute a
POST
request tohttps://api.instagram.com/oauth/access_token
withx-www-form-urlencoded
paramsclient_id
: {your-client-id}client_secret
: {your-client-secret}grant_type
: authorization_coderedirect_uri
: {a-valid-redirect-url}code
: {the code you extracted from query string}
- You should get a short-lived access-token response such as:
{
"access_token": "IGQVxxxxxxxxxx…",
"user_id": xxxxxxxxxx
}
- Exchange your short-lived access-token with a long-lived one: use Postman to execute a
GET
request tohttps://graph.instagram.com/access_token
with query params:client_id
: {your-client-id}client_secret
: {your-client-secret}grant_type
: ig_exchange_tokenaccess_token
: {the short-lived access_token}
- You should get a long-lived access-token response such as:
{
"access_token": "IGQxxxxx…",
"token_type": "bearer",
"expires_in": 5169852
}