facebookinstagraminstagram-apiinstagram-graph-api

Why can't I generate user token in Instagram API?


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.

allow permissions

blank


Solution

  • 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):

    1. 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
    
    1. Login to your Instagram account and accept your application to access your data
    2. You should be redirected to {a-valid-redirect-url}?code=xxxxx#_ then copy to {code} query string value without the #_ at the end
    3. Use Postman to execute a POST request to https://api.instagram.com/oauth/access_token with x-www-form-urlencoded params
      • client_id: {your-client-id}
      • client_secret: {your-client-secret}
      • grant_type: authorization_code
      • redirect_uri: {a-valid-redirect-url}
      • code: {the code you extracted from query string}
    4. You should get a short-lived access-token response such as:
    {
        "access_token": "IGQVxxxxxxxxxx…",
        "user_id": xxxxxxxxxx
    }
    
    1. Exchange your short-lived access-token with a long-lived one: use Postman to execute a GET request to https://graph.instagram.com/access_token with query params:
      • client_id: {your-client-id}
      • client_secret: {your-client-secret}
      • grant_type: ig_exchange_token
      • access_token: {the short-lived access_token}
    2. You should get a long-lived access-token response such as:
    {
        "access_token": "IGQxxxxx…",
        "token_type": "bearer",
        "expires_in": 5169852
    }