Facebook Token Management: Exchange Short Lived for Long-Lived Tokens

This workflow automates the exchange of short-lived Facebook user access tokens for long-lived tokens (with a 60-day validity) and page tokens (non-expiring), replacing manual token management via Facebook’s developer portal, which is error-prone and requires frequent re-authentication. Manual processes waste hours monthly, risking API downtime for social media automation. The workflow validates inputs, fetches tokens via Facebook’s Graph API, and formats outputs for downstream use. Key nodes include Manual Trigger for testing, Set for input validation (client_id, client_secret, user_access_token), IF for credential and response checks, HTTP Request for token exchanges (user and page), and Set for success/error responses. It benefits marketing teams or developers managing 10+ Facebook pages, enabling seamless API integrations for posting or analytics, reducing token refresh cycles and ensuring uninterrupted workflows.\n\nSaves 3-5 hours monthly managing tokens for 10+ pages, cutting API downtime by 90%. Ideal for small to medium marketing agencies or social media managers. Requires a Facebook App (free) and n8n cloud ($20/month) or self-hosted (free). Scalable to 100+ pages but limited by Facebook’s API rate limits (200 calls/hour). No external webhook needed.\n\nInstall n8n from n8n.io or cloud.n8n.io ($20/month unlimited). Create a Facebook App at developers.facebook.com, get client_id and client_secret (Apps > Settings), and short-lived user_access_token via Graph API Explorer. Set environment variables in n8n: FACEBOOK_CLIENT_ID, FACEBOOK_CLIENT_SECRET, FACEBOOK_USER_ACCESS_TOKEN, FACEBOOK_APP_SCOPED_USER_ID (from user profile). Configure Set node for inputs, HTTP Request URLs for Graph API (v20.0), and IF conditions for validation. No webhook setup required; uses internal triggers.\n\nTest manually: Run workflow with valid credentials, verify long-lived user token (expires_in ~5183999) and page tokens in Success Response. Common errors: invalid user_access_token (regenerate via Graph API Explorer), missing permissions (check App Review), or rate limits (add Wait node). Deploy by activating; monitor logs. Maintain by updating tokens every 60 days, adding Schedule Trigger for automation, and storing outputs in a database for reuse.", "businessValue": "Saves 3-5 hours/month automating token management for 10+ Facebook pages", "setupTime": "20-30 minutes", "difficulty": "Intermediate", "requirements": ["Facebook App (free, with client_id and client_secret)", "Valid short-lived user access token", "n8n cloud ($20/month) or self-hosted (free)"], "useCase": "Automating long-lived token retrieval for Facebook API integrations"

$5.49

Workflow steps: 12

Integrated apps: manualTrigger, set, if

Facebook Token Management: Exchange Short Lived for Long-Lived Tokens preview