Facebook-Token-Update
Fortgeschritten
Dies ist ein Marketing-Bereich Automatisierungsworkflow mit 12 Nodes. Hauptsächlich werden If, Code, Webhook, HttpRequest, RespondToWebhook und andere Nodes verwendet. Facebook-Token-Beschaffung und -Verwaltung
Voraussetzungen
- •HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
- •Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Verwendete Nodes (12)
Kategorie
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
"id": "MVhWWLZv7PhhLSq2",
"meta": {
"instanceId": "2c69a61055797162319204105e5a124e409f0c7fbfaba08ee106324374f4ae73",
"templateCredsSetupCompleted": true
},
"name": "Facebook Token Mew",
"tags": [],
"nodes": [
{
"id": "ecd428ff-673c-435c-a6b3-723ae6f3f88d",
"name": "Webhook-Trigger",
"type": "n8n-nodes-base.webhook",
"position": [
1680,
280
],
"webhookId": "9e37ff8f-66fd-417b-97af-570e52622d7b",
"parameters": {
"path": "facebook-login",
"options": {},
"responseMode": "responseNode"
},
"typeVersion": 2
},
{
"id": "7fe9fcb7-49f3-4628-8a9f-2027f9dffd61",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
2360,
280
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "and",
"conditions": [
{
"id": "ce391d94-03af-42d1-ae73-91bdb2e93c00",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $('Webhook').first().json.query.code }}",
"rightValue": "login"
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "ded6d8fa-3add-4084-a9f2-172a5d51158b",
"name": "Short-Lived Token",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueErrorOutput",
"position": [
2720,
140
],
"parameters": {
"url": "https://graph.facebook.com/v21.0/oauth/access_token",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "client_id",
"value": "={{ $('Config').first().json.app_id }}"
},
{
"name": "redirect_uri",
"value": "={{ $('Config').first().json.fb_redirect_uri }}"
},
{
"name": "client_secret",
"value": "={{ $('Config').first().json.app_secret }}"
},
{
"name": "code",
"value": "={{ $('Webhook').first().json.query.code }}"
}
]
}
},
"retryOnFail": true,
"typeVersion": 4.2,
"alwaysOutputData": false,
"waitBetweenTries": 5000
},
{
"id": "27fed69c-e476-4e19-870e-f26ed707e36a",
"name": "Long-Lived Token",
"type": "n8n-nodes-base.httpRequest",
"position": [
3000,
-100
],
"parameters": {
"url": "https://graph.facebook.com/v21.0/oauth/access_token",
"options": {},
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "grant_type",
"value": "fb_exchange_token"
},
{
"name": "client_id",
"value": "={{ $('Config').first().json.app_id }}"
},
{
"name": "client_secret",
"value": "={{ $('Config').first().json.app_secret }}"
},
{
"name": "fb_exchange_token",
"value": "={{ $('Short-Lived Token').first().json.access_token }}"
}
]
}
},
"retryOnFail": true,
"typeVersion": 4.2,
"waitBetweenTries": 5000
},
{
"id": "94e38177-b72f-4e99-9e2f-e43bd679589b",
"name": "Haftnotiz",
"type": "n8n-nodes-base.stickyNote",
"position": [
1660,
-800
],
"parameters": {
"width": 920,
"height": 900,
"content": "### Instructions to Get a 2-Month Facebook Token\nRun n8n with tunnel model - Or user: Ngrok, Cloudflare Tunnel\n\n1. **Activate the App**:\n - Launch the app. In the top-right corner near the **Save** button, you will see a status button labeled **Inactive**.\n - Switch this button to **Active** (it will turn green) to activate the app.\n\n2. **Access the Webhook URL**:\n - Visit the following URL (fb_redirect_uri): \n https://localhost:5678/webhook/facebook-login?type=login\n\n3. **Follow the Steps**:\n - Complete the on-screen instructions to finish the process.\n - Once done, you will receive a **Facebook Token** valid for **2 months (60 days)**.\n\n\n### Instructions to Check Token Status and Get Page Token\n1. **Check Token Status**:\n - Go to [Facebook Access Token Debugger](https://developers.facebook.com/tools/debug/accesstoken/).\n - Paste your **User Token** into the debugger to view details such as expiration date, permissions, and token status.\n\n2. **Get Page Token for Posting**:\n - A **User Token** only grants access to personal information. To post on a Page, you need a **Page Token**.\n - Send a GET request to the following endpoint (replace `{user-access-token}` with your User Token):\n ```\n GET https://graph.facebook.com/v21.0/me/accounts?access_token={user-access-token}\n ```\n - The response will include a list of Pages you manage along with their corresponding **Page Tokens**.\n\n3. **Use the Page Token**:\n - Use the **Page Token** to perform actions such as posting, managing comments, or other tasks on the Page.\n\n**Note**:\n- Ensure the User Token has the necessary permissions like `pages_manage_posts`, `pages_read_engagement`, etc., to retrieve the Page Token.\n- The Page Token will have the same expiration as the User Token (approximately 60 days) and can be renewed.\n\n\n`https://github.com/luuhung93/n8n-json`"
},
"typeVersion": 1
},
{
"id": "4af7f1f6-9479-4489-9282-7083cd29649c",
"name": "Redirect URL",
"type": "n8n-nodes-base.code",
"position": [
2980,
480
],
"parameters": {
"jsCode": "const config = $('Config').first().json;\n\n\nconst generateRandomState = () => {\n\treturn Math.random().toString(36).substring(2, 15) +\n\t\tMath.random().toString(36).substring(2, 15);\n}\nconst state = generateRandomState();\n\nconst correctScopes = [\n 'publish_video',\n\t\t'pages_show_list',\n\t\t'business_management',\n 'pages_read_engagement',\n 'pages_read_user_content',\n 'pages_manage_metadata',\n 'pages_manage_posts',\n 'pages_manage_engagement',\n\t];\n\nconst authUrl = `https://www.facebook.com/v22.0/dialog/oauth?client_id=${config.app_id}&redirect_uri=${config.fb_redirect_uri}&scope=${correctScopes.join(',')}&response_type=code&state=${state}`;\n\nreturn [{\n authUrl\n}];"
},
"typeVersion": 2
},
{
"id": "b415e387-17ed-4451-ae7d-b8d1fdf8ee06",
"name": "Redirect",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
3740,
480
],
"parameters": {
"options": {},
"redirectURL": "={{ $json.authUrl }}",
"respondWith": "redirect"
},
"typeVersion": 1.1
},
{
"id": "d59290d9-79b5-4212-a8ad-a1a9e074bbf2",
"name": "Haftnotiz1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1840,
140
],
"parameters": {
"width": 420,
"height": 480,
"content": "Edit:\n - fb_redirect_uri\n - app_id\n - app_secret\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nGo to the [Facebook App](https://developers.facebook.com/apps/).\n - Select **Facebook Login** from the left-hand menu.\n - Click on **Settings**.\n - In the **Valid OAuth Redirect URIs** section, add the URL (fb_redirect_uri): `https://localhost:5678/webhook/facebook-login`"
},
"typeVersion": 1
},
{
"id": "952f17fa-efdf-4523-9d9b-ff071670e425",
"name": "Haftnotiz2",
"type": "n8n-nodes-base.stickyNote",
"position": [
2460,
460
],
"parameters": {
"width": 640,
"height": 760,
"content": "\n\n\n\n### Guide to Editing `correctScopes`\n\n1. **Add a Permission**:\n - Add the permission to the `correctScopes` array. For example:\n ```javascript\n const correctScopes = [\n 'pages_manage_posts', // Existing permission\n 'pages_messaging', // New permission added\n ];\n ```\n\n2. **Edit a Permission**:\n - Replace a permission in the `correctScopes` array. For example:\n ```javascript\n const correctScopes = [\n 'pages_manage_posts', // Existing permission\n 'pages_messaging', // New permission replacing the old one\n ];\n ```\n\n3. **Remove a Permission**:\n - Remove a permission from the `correctScopes` array. For example:\n ```javascript\n const correctScopes = [\n 'pages_manage_posts', // Keep this permission\n // 'pages_messaging', // Remove this permission\n ];\n ```\n\n4. **View Available Permissions**:\n - Refer to the full list of permissions at [Facebook Permissions](https://developers.facebook.com/docs/permissions/).\n\nSimply edit the `correctScopes` array; no need to worry about other parts.\n"
},
"typeVersion": 1
},
{
"id": "dbc712ba-1a95-4041-ac27-824d804726bc",
"name": "Token",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
3700,
-100
],
"parameters": {
"options": {},
"respondWith": "text",
"responseBody": "={{ $json.access_token }}"
},
"typeVersion": 1.1
},
{
"id": "560d3c3f-a0e8-432e-904f-71cd7525fd0d",
"name": "Haftnotiz3",
"type": "n8n-nodes-base.stickyNote",
"position": [
3280,
-180
],
"parameters": {
"width": 280,
"content": "By default, the token will be displayed on the screen. However, you can add a `node` to save the token into your database."
},
"typeVersion": 1
},
{
"id": "99e67d66-5179-4186-b78f-ced80ab5dd82",
"name": "Config",
"type": "n8n-nodes-base.set",
"position": [
1980,
280
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c210cd1e-ff2d-47cb-b9c4-af1e9a91ec71",
"name": "fb_redirect_uri",
"type": "string",
"value": "https://localhost:5678/webhook/facebook-login"
},
{
"id": "3f24bd07-905f-4c3c-bd07-2661e0a95d7a",
"name": "app_id",
"type": "string",
"value": "12345678900000"
},
{
"id": "51de3a11-3e7f-4c8e-9c2c-63ae28a14eb8",
"name": "app_secret",
"type": "string",
"value": "aaabbbcccceedb6f9c91993c871"
}
]
}
},
"typeVersion": 3.4
}
],
"active": false,
"pinData": {},
"settings": {
"timezone": "Asia/Ho_Chi_Minh",
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1"
},
"versionId": "c2d0b26b-3366-424a-a741-20649907f008",
"connections": {
"7fe9fcb7-49f3-4628-8a9f-2027f9dffd61": {
"main": [
[
{
"node": "ded6d8fa-3add-4084-a9f2-172a5d51158b",
"type": "main",
"index": 0
}
],
[
{
"node": "4af7f1f6-9479-4489-9282-7083cd29649c",
"type": "main",
"index": 0
}
]
]
},
"99e67d66-5179-4186-b78f-ced80ab5dd82": {
"main": [
[
{
"node": "7fe9fcb7-49f3-4628-8a9f-2027f9dffd61",
"type": "main",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "99e67d66-5179-4186-b78f-ced80ab5dd82",
"type": "main",
"index": 0
}
]
]
},
"4af7f1f6-9479-4489-9282-7083cd29649c": {
"main": [
[
{
"node": "b415e387-17ed-4451-ae7d-b8d1fdf8ee06",
"type": "main",
"index": 0
}
]
]
},
"27fed69c-e476-4e19-870e-f26ed707e36a": {
"main": [
[
{
"node": "dbc712ba-1a95-4041-ac27-824d804726bc",
"type": "main",
"index": 0
}
]
]
},
"ded6d8fa-3add-4084-a9f2-172a5d51158b": {
"main": [
[
{
"node": "27fed69c-e476-4e19-870e-f26ed707e36a",
"type": "main",
"index": 0
}
],
[
{
"node": "4af7f1f6-9479-4489-9282-7083cd29649c",
"type": "main",
"index": 0
}
]
]
}
}
}Häufig gestellte Fragen
Wie verwende ich diesen Workflow?
Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.
Für welche Szenarien ist dieser Workflow geeignet?
Fortgeschritten - Marketing
Ist es kostenpflichtig?
Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.
Verwandte Workflows
Reddit-Beiträge mit KI in kurze Videos umwandeln
Verwenden Sie KI, um Reddit-Beiträge in kurze Videos umzuwandeln
If
Set
Code
+
If
Set
Code
43 NodesArtur
Künstliche Intelligenz
Newsletter-Verwaltung (n8n + Bolt.new)
Stellenkommunikations-Automatisierungssystem (N8N, Bolt.new, RapidAPI, Mails.so & ChatGPT)
If
Code
Gmail
+
If
Code
Gmail
43 NodesJoseph
Künstliche Intelligenz
[Template] KI-Haustierladen v8
🐥 KI-Assistent für Tiernahrungsshops - Integriert GPT-4o, Google Kalender und WhatsApp/Instagram/Facebook
If
N8n
Set
+
If
N8n
Set
244 NodesAmanda Benks
Vertrieb
YouTube-Video-Clip-Extraction-API
API zur Extraktion prädiktiver Highlights aus YouTube-Videos
If
Set
Filter
+
If
Set
Filter
18 NodesMax T
Marketing
Automatisierung der Veröffentlichung von RSS-Inhalten als Blogbeiträge mit GPT-4o, WordPress und LinkedIn
Automatisierung der Veröffentlichung von RSS-Inhalten als Blogartikel auf WordPress und LinkedIn durch KI
If
Set
Code
+
If
Set
Code
40 NodesImmanuel
Künstliche Intelligenz
WordPress-Content-Generator v3
WordPress-Inhaltsgenerator v3
If
Set
Code
+
If
Set
Code
102 NodesAlex Kim
Künstliche Intelligenz
Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes12
Kategorie1
Node-Typen6
Autor
L Hung
@meow-cdeExterne Links
Auf n8n.io ansehen →
Diesen Workflow teilen