Need to find your Instagram access token and account ID? Here's the fastest way!
Run this one command and follow the prompts:
cd /Users/jeorryb/pyasan
./scripts/setup_instagram_credentials.shThis script will:
- ✅ Convert your short-lived token to a long-lived one
- ✅ Find your Instagram Business Account ID
- ✅ Verify everything works
- ✅ Optionally add secrets to GitHub automatically
-
Go to Graph API Explorer
-
Select your app (top right dropdown)
-
Add permissions (click "Permissions" button):
instagram_basicinstagram_content_publishpages_read_engagementpages_show_list
-
Click "Generate Access Token"
-
Convert to long-lived token (expires in 60 days):
curl "https://graph.facebook.com/v20.0/oauth/access_token?grant_type=fb_exchange_token&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&fb_exchange_token=YOUR_SHORT_TOKEN"Get your App ID and Secret from: https://developers.facebook.com/apps/ → Your App → Settings → Basic
export INSTAGRAM_ACCESS_TOKEN="your_long_lived_token"
python examples/find_instagram_id.pyThis will show your Instagram Business Account ID.
export INSTAGRAM_ACCOUNT_ID="your_account_id"
python scripts/diagnose_instagram_token.pyYou should see ✅ marks confirming everything is set up correctly.
Go to: https://github.com/jeorryb/pyasan/settings/secrets/actions
Add these secrets:
INSTAGRAM_ACCESS_TOKEN= your long-lived tokenINSTAGRAM_ACCOUNT_ID= your Instagram Business Account IDFACEBOOK_APP_ID= your app IDFACEBOOK_APP_SECRET= your app secret
# Just pass your token directly
python examples/find_instagram_id.py YOUR_ACCESS_TOKENProblem: Your Instagram is a Personal account, not Business
Solution:
- Open Instagram app
- Settings → Account → Switch to Professional Account
- Choose "Business"
- Link to a Facebook Page
Problem: Token expired or invalid
Solution: Generate a new token (see Step 1 above)
Problem: No Facebook Page linked to your Instagram
Solution:
- Create a Facebook Page: https://facebook.com/pages/create
- Link to Instagram: Instagram → Settings → Account → Linked Accounts → Facebook
Solution: Run the automatic renewal workflow monthly:
gh workflow run renew-instagram-token.ymlOr wait for it to run automatically on the 1st of each month.
- Full credentials guide:
docs/FIND_INSTAGRAM_CREDENTIALS.md - Full setup guide:
docs/INSTAGRAM_GRAPH_API_SETUP.md
# Test your token validity
curl "https://graph.facebook.com/v20.0/debug_token?input_token=YOUR_TOKEN&access_token=YOUR_TOKEN"
# Get your account info
curl "https://graph.facebook.com/v20.0/YOUR_ACCOUNT_ID?fields=id,username,media_count&access_token=YOUR_TOKEN"
# List your Facebook pages
curl "https://graph.facebook.com/v20.0/me/accounts?access_token=YOUR_TOKEN"
# Get Instagram account from page
curl "https://graph.facebook.com/v20.0/PAGE_ID?fields=instagram_business_account&access_token=YOUR_TOKEN"Run this anytime to check your setup:
cd /Users/jeorryb/pyasan
export INSTAGRAM_ACCESS_TOKEN="your_token"
export INSTAGRAM_ACCOUNT_ID="your_id"
python scripts/diagnose_instagram_token.pyNeed more help? Check the detailed guides in the docs/ folder! 📖