Setting up a Meta app for the Facebook and Instagram APIs
To call Meta APIs you need your own app on developers.facebook.com: create it with the right use cases, copy the App ID and App Secret from App settings → Basic, and for a Business-type app create a Facebook Login for Business configuration to get a config_id. Then add the redirect URI and webhooks, and pass App Review and Business Verification before serving accounts you don't manage.
Updated:
What do you get from a Meta app?
A Meta app gives you three values: the App ID (public identifier sent in the login URL), the App Secret (private: exchanging the login code for a token, signing appsecret_proof and verifying webhook signatures) and an optional Configuration ID (config_id) — a Facebook Login for Business configuration that replaces the permission list (scope) in the login URL.
One Meta app covers Facebook Pages, Instagram accounts linked to a Page, Lead Ads and the Marketing API. Instagram without a Facebook Page uses a different product and different keys — see the Instagram Login guide.
The App Secret must never reach a browser, a mobile app or a public repository. If it leaks, generate a new one in the dashboard and replace it everywhere, including the “Kalitlar” (Keys) page in the Socialift dashboard.
Key terms
- Use case
- The integration scenario you pick when creating the app (for example “Manage everything on your Page”). Permissions and products come from it. Use cases can't be removed after creation — only compatible ones can be added.
- Facebook Login for Business
- The login product for Business-type apps. Permissions are chosen in a configuration in the dashboard, and your code passes only its ID (
config_id). - Standard vs Advanced Access
- With Standard Access only people who have a role on the app can grant permissions. To serve Pages and accounts you don't manage, each permission needs Advanced Access through App Review.
- Business Verification
- Verifying your company with Meta. An app requesting Advanced Access must be connected to a verified business portfolio.
How to create and configure a Meta app
Create the app
On developers.facebook.com/apps start creating an app: enter the name and contact email, then choose use cases (for example “Manage everything on your Page”). If you need Facebook Login for Business with
config_idand no listed use case fits, choose “Other” and then the Business app type.Connect a business portfolio
The wizard offers to connect a verified or unverified business portfolio, or to create one. Connect the company that will own the integration — that's the business you'll verify later for Advanced Access.
Copy the App ID and App Secret
Both are under App settings → Basic; the App ID is also shown at the top of the dashboard. Keep the secret in environment variables or a secret manager.
Add the redirect URI
Add the Facebook Login for Business product (your use case may already include it). In its settings, put your callback address into Valid OAuth Redirect URIs. With Strict Mode, Meta requires an exact match: a different path or a query parameter not in the list is rejected.
Create a configuration and copy config_id
Under Configurations create a configuration (or start from a template): name, access token type, business assets and permissions. Choose User access token: Socialift's login flow exchanges the code for a long-lived user token and then reads Pages. System user tokens require an extra login URL parameter (
override_default_response_type) that this flow doesn't send. Copy the Configuration ID.Add permissions to the use case
On the use case customization screen, add only the permissions from the table below that your integration actually uses. Per Meta's docs, the most common App Review rejection reason is requesting a permission or feature the app doesn't need.
Configure webhooks
Your endpoint needs HTTPS with a valid certificate (self-signed isn't supported). Enter the Callback URL and Verify token, confirm, then subscribe to fields: Page object —
leadgen(Lead Ads) andfeed(posts and comments); Instagram object —comments,mentionsandmessagesfor Direct. Each Page must then install the app viasubscribed_apps— without it no events arrive.Add roles and testers
In the Roles panel invite administrators, developers and testers. Until App Review, permissions can be granted only by people with a role on the app (or on the business that owns it) — that's how you test with your own Pages.
Pass App Review and Business Verification
To serve Pages and accounts you don't manage, each permission needs Advanced Access. Every permission needs its own description and a screen recording (the user grants it, the app uses it); at least one successful API call with that permission within 30 days before submitting; a privacy policy URL and a 1024×1024 app icon. Advanced Access requires Business Verification.
How to add the Meta app to Socialift
Open “Kalitlar” → “Meta (Facebook) app”
In the dashboard open “Kalitlar” (Keys) and expand the “Meta (Facebook) app” card. The side block “Konsolga ko'chiring” (Copy to console) shows the Redirect URI even before you save a key — paste it into Valid OAuth Redirect URIs.
Fill in the fields
App ID and App secret are required. Configuration ID is optional: when set, the login URL carries
config_idand the “Scope'lar” (Scopes) field is not used. Leave it empty for a Consumer app — then thescopelist is sent (empty “Scope'lar” = default list, comma- or space-separated).Click “Saqlash va tekshirish” (Save and verify)
Socialift asks Meta for an app access token with your ID and secret: a match marks the key as verified, a rejection shows Meta's error. This checks only the ID/secret pair — the redirect URI,
config_idand permissions are checked on the first real login. The secret is stored encrypted and never returned in full; leave the field empty when editing to keep the current one.Copy the webhook and callback URLs
After saving, the card shows Webhook URL, Webhook verify token, Deauthorize callback and Data deletion callback. Your app gets its own webhook URL, and incoming events are verified with your App Secret. Paste the webhook pair into the Webhooks settings, the deauthorize URL into the Facebook Login settings and the data deletion URL into the field under App settings → Basic.
Connect an account and sync Pages
In “Ulanishlar” (Connections) click “Ulash” (Connect) on the Facebook card, then “Page'larni sinxronlash” (Sync Pages) — your Pages and their linked Instagram accounts are added. Subscribe each Page to webhooks from Playground (the “Page'lar va webhook” section) or with
fb.subscribe_pagein the SDK.
Which permissions does the app need?
This is Socialift's default “Scope'lar” list. When you use config_id, choose the same permissions inside the configuration.
| Permission | What it allows | Where the SDK needs it |
|---|---|---|
public_profile | Default profile fields of the person logging in | Login |
email | Primary email address | Login |
pages_show_list | List of Pages the person manages | fb.pages |
pages_read_engagement | Page content and metadata | fb.posts, fb.comments, fb.post_insights |
pages_manage_posts | Create, edit and delete Page posts | fb.publish_post, fb.delete_post |
pages_manage_engagement | Create, edit and delete comments on the Page | fb.reply_comment, fb.hide_comment |
read_insights | Page and post insights | fb.post_insights |
pages_manage_metadata | Subscribe the Page to webhooks and update its settings | fb.subscribe_page |
pages_messaging | The Page's Messenger conversations; needed for the Page messages webhook field | Default list only — Socialift has no Messenger methods |
leads_retrieval | Read data collected by Lead Ads forms | fb.lead_forms, fb.leads |
pages_manage_ads | Manage ads associated with the Page | fb.lead_forms |
instagram_basic | Instagram profile and media via the Page | ig.profile, ig.media |
instagram_content_publish | Publish Instagram posts | ig.publish |
instagram_manage_comments | Create, hide and delete Instagram comments | ig.comments, ig.reply_comment |
instagram_manage_insights | Instagram account and media insights | ig.insights, ig.media_insights |
instagram_manage_messages | Read and reply to Instagram Direct | ig.conversations, ig.send_message |
ads_read | Ads reporting (Ads Insights) | Ads.campaigns, Ads.insights_rows |
ads_management | Manage ad accounts and ads | Ads.create_campaign, fb.ad_context |
business_management | Business Manager API | Default list |
Notes and limits
Per Meta's docs, retrieving leads with ad-level data needs ads_management, leads_retrieval, pages_show_list, pages_read_engagement and pages_manage_ads together. Instagram Direct via a Page needs instagram_basic, instagram_manage_messages and pages_manage_metadata.
Using the keys in the Python SDK
Facebook.from_env() reads FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CONFIG_ID and META_GRAPH_VERSION from the environment.
import asyncio
import secrets
from socialift import Facebook
REDIRECT_URI = "https://example.com/auth/facebook/callback" # same as in Valid OAuth Redirect URIs
async def main() -> None:
# FACEBOOK_APP_ID, FACEBOOK_APP_SECRET, FACEBOOK_CONFIG_ID, SOCIALIFT_LICENSE_KEY
async with Facebook.from_env() as fb:
state = secrets.token_urlsafe(32) # store in the session, compare in the callback
print(fb.login_url(redirect_uri=REDIRECT_URI, state=state))
code = input("code: ")
token = await fb.exchange_code(code, redirect_uri=REDIRECT_URI)
print(await fb.granted_scopes(token.access_token)) # permissions actually granted
for page in await fb.pages(token.access_token):
await fb.subscribe_page(page.id, page.access_token, fields=["leadgen", "feed"])
asyncio.run(main())Explicitly: Facebook(app_id="...", app_secret="...", config_id="..."). With config_id, login_url sends config_id instead of scope; without it, the scopes list.
The redirect_uri in exchange_code must match the one in the login URL character for character.
Common mistakes
- The redirect URI differs from Valid OAuth Redirect URIs (http vs https, trailing
/, an extra query parameter). - Instagram app ID/secret entered in the Meta card (or the other way round) — they are different keys.
- The configuration uses a System user access token — Socialift's login flow expects a User access token.
- Configuration ID is set, but permissions are being changed in “Scope'lar” — in that case change them in the configuration.
- Webhooks are configured at app level, but the Page isn't subscribed via
subscribed_apps— no events arrive. - Testing before App Review with an account that has no role on the app — permissions aren't granted.
- Advanced Access requested for permissions the app doesn't use — App Review rejects it.
- The App Secret sits in frontend code or in a repository.
Frequently asked questions
Where do I find the Facebook App ID and App Secret?
In the Meta App Dashboard under App settings → Basic; the App ID is also shown at the top of the dashboard. Keep the App Secret on the server only — in Socialift it's stored encrypted on the “Kalitlar” (Keys) page.
What is config_id and do I need it?
config_id is the ID of a Facebook Login for Business configuration: permissions, token type and assets are chosen in the dashboard, and your code passes only the ID. It's recommended for Business-type apps. For a Consumer app leave it empty and request permissions via scope.
Can I test without App Review?
Yes. Under Standard Access, people with a role on the app (administrator, developer, tester) can grant permissions, so you can fully test with your own Pages and accounts. App Review and Advanced Access are needed only to connect accounts you don't manage.
Why aren't Page webhooks arriving?
Most often the Page hasn't installed the app via subscribed_apps — app-level settings alone aren't enough. Also check HTTPS with a valid certificate, the verify token match and that the token has pages_manage_metadata.
Do I need a separate app for Instagram?
Not for Instagram via a Page — the same Meta app with instagram_* permissions is enough. For Instagram Login without a Facebook Page, the same Meta app has a separate Instagram app ID and secret, which go into the “Instagram Login app” card on the “Kalitlar” (Keys) page.
What happens if I delete the Meta key in “Kalitlar”?
If accounts were connected through it, Socialift lists them and warns you, because their tokens don't work without that app's secret. Choosing “Baribir o'chirish va uzish” (Delete and disconnect anyway) removes the key and disconnects them. Unchecking “Faol” (Active) instead moves new connections to the Socialift key while existing ones keep working.