8
n8n 한국어amn8n.com

페이스북 토큰 업데이트

중급

이것은Marketing분야의자동화 워크플로우로, 12개의 노드를 포함합니다.주로 If, Code, Webhook, HttpRequest, RespondToWebhook 등의 노드를 사용하며. Facebook 토큰 획득 및 관리

사전 요구사항
  • HTTP Webhook 엔드포인트(n8n이 자동으로 생성)
  • 대상 API의 인증 정보가 필요할 수 있음

카테고리

워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "id": "MVhWWLZv7PhhLSq2",
  "meta": {
    "instanceId": "2c69a61055797162319204105e5a124e409f0c7fbfaba08ee106324374f4ae73",
    "templateCredsSetupCompleted": true
  },
  "name": "Facebook Token Mew",
  "tags": [],
  "nodes": [
    {
      "id": "ecd428ff-673c-435c-a6b3-723ae6f3f88d",
      "name": "Webhook 트리거",
      "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": "메모",
      "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": "메모1",
      "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": "메모2",
      "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": "메모3",
      "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
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

중급 - 마케팅

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
중급
노드 수12
카테고리1
노드 유형6
난이도 설명

일정 경험을 가진 사용자를 위한 6-15개 노드의 중간 복잡도 워크플로우

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34