Issue
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.
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):
- 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
POSTrequest tohttps://api.instagram.com/oauth/access_tokenwithx-www-form-urlencodedparamsclient_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
GETrequest tohttps://graph.instagram.com/access_tokenwith 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
}
Answered By - Ambroise Maupate Answer Checked By - David Goodson (PHPFixing Volunteer)


0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.