AutomationFlowsWeb Scraping › Automate Line & Google Account Linking with Oauth2 Authentication

Automate Line & Google Account Linking with Oauth2 Authentication

Bys3110 @s3110 on n8n.io

This workflow automates the process of linking a new user on your LINE Official Account to their Google Account. When a user adds your LINE account as a friend, this workflow automatically sends them a message with a unique authentication link. After the user approves the…

Webhook trigger★★★☆☆ complexity12 nodesHTTP Request
Web Scraping Trigger: Webhook Nodes: 12 Complexity: ★★★☆☆ Added:

This workflow corresponds to n8n.io template #10950 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "bBRkNT4Ea1ZqG6gi",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [],
  "nodes": [
    {
      "id": "26a73587-8928-4e52-8dbf-d2268a1ac0c9",
      "name": "Redirect to LINE OA",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        352,
        96
      ],
      "parameters": {
        "options": {
          "responseCode": 302
        },
        "redirectURL": "https://line.me/R/ti/p/@YOUR_LINE_OFFICIAL_ACCOUNT_ID",
        "respondWith": "redirect"
      },
      "typeVersion": 1.4
    },
    {
      "id": "3e9598b9-66c4-4f00-b6e6-e3eccc103e88",
      "name": "Get Google Access Token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        96
      ],
      "parameters": {
        "url": "https://oauth2.googleapis.com/token",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"code\": \"{{ $json.query.code }}\",\n  \"client_id\": \"YOUR_GOOGLE_CLIENT_ID\",\n  \"client_secret\": \"YOUR_GOOGLE_CLIENT_SECRET\",\n  \"redirect_uri\": \"YOUR_N8N_WEBHOOK_URL_FOR_GOOGLE\",\n  \"grant_type\": \"authorization_code\"\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.3
    },
    {
      "id": "29e9c3d9-8fd5-4922-bbe6-bf0f6e6dc589",
      "name": "Get Google User Info",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -96,
        96
      ],
      "parameters": {
        "url": "https://www.googleapis.com/oauth2/v2/userinfo",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "ef6a41c4-f6d4-4a0c-aaeb-2725a6d7fd04",
      "name": "Send Completion Message to LINE",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        96
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/push",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"to\": \"{{ $('Google Auth Callback').item.json.query.state }}\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"Google\u30a2\u30ab\u30a6\u30f3\u30c8\u3068\u306e\u9023\u643a\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01\\n\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\u3002\\n\\n\u30a2\u30ab\u30a6\u30f3\u30c8\u60c5\u5831\\n{{ $json.email }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "93f3b1b0-203c-452b-aa54-05671d82f179",
      "name": "If Follow Event",
      "type": "n8n-nodes-base.if",
      "position": [
        -320,
        -320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1c7b8187-d60b-4601-bd65-a1d9ac35ea8c",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.events[0].type }}",
              "rightValue": "follow"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f00fe94b-9860-45d6-8e82-13f8ea8c4bcf",
      "name": "Create Google Auth URL",
      "type": "n8n-nodes-base.set",
      "position": [
        -96,
        -320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7ccb596a-cf2d-43f8-9e1a-c35a2189e040",
              "name": "googleAuthUrl",
              "type": "string",
              "value": "=https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile&access_type=offline&response_type=code&state={{ $('LINE Webhook').item.json.body.events[0].source.userId }}&redirect_uri=YOUR_N8N_WEBHOOK_URL_FOR_GOOGLE&client_id=YOUR_GOOGLE_CLIENT_ID"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9a8ff025-4e28-4cd6-a842-9a032aa97e5c",
      "name": "Send Auth Link to LINE",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        128,
        -320
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"replyToken\": \"{{ $('LINE Webhook').item.json.body.events[0].replyToken }}\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"\u53cb\u3060\u3061\u8ffd\u52a0\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3059\uff01\\n\u307e\u305a\u306fGoogle\u30a2\u30ab\u30a6\u30f3\u30c8\u3068\u9023\u643a\u3057\u3066\u3001\u3059\u3079\u3066\u306e\u6a5f\u80fd\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\"\n    },\n    {\n      \"type\": \"text\",\n      \"text\": \"\u9023\u643a\u306f\u3053\u3061\u3089\u306e\u30ea\u30f3\u30af\u304b\u3089\u304a\u9858\u3044\u3057\u307e\u3059\ud83d\udc47\\n{{ $json.googleAuthUrl }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.3
    },
    {
      "id": "d63e7528-aaae-4c8b-92b9-045ce4bc119e",
      "name": "LINE Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -544,
        -320
      ],
      "parameters": {
        "path": "YOUR_WEBHOOK_PATH_FOR_LINE",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2.1
    },
    {
      "id": "91b77beb-10e2-4398-a5c2-3988ee07d192",
      "name": "Google Auth Callback",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -544,
        96
      ],
      "parameters": {
        "path": "YOUR_WEBHOOK_PATH_FOR_GOOGLE",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c78d8f0c-4189-467c-bdb2-7f1a32a4f7ac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -480
      ],
      "parameters": {
        "color": 4,
        "width": 1136,
        "height": 336,
        "content": "### Workflow 1: LINE Follow Event & Authentication Start\n\nThis workflow activates when a user adds your LINE Official Account. It listens for the \"follow\" event, generates a unique Google OAuth2 authentication URL that includes the user's LINE ID, and sends it in a welcome message. This action securely initiates the account linking process for new followers."
      },
      "typeVersion": 1
    },
    {
      "id": "206575c3-9369-4bc6-bfc8-8778e0ad176d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -32
      ],
      "parameters": {
        "color": 5,
        "width": 1136,
        "height": 336,
        "content": "### Workflow 2: Google Auth Callback & Linking Completion\n\nThis workflow serves as the redirect URI for Google's OAuth2 flow. It receives the authorization code, exchanges it for an access token, and fetches the user's profile. It then sends a confirmation message via LINE and redirects the user's browser, seamlessly completing the account linking process."
      },
      "typeVersion": 1
    },
    {
      "id": "bb596e53-c8f6-423f-81c4-e58dc16813cc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1760,
        -480
      ],
      "parameters": {
        "width": 1056,
        "height": 784,
        "content": "# LINE x Google Account Linking Workflow\n\nThis workflow automates the process of linking a new user on your LINE Official Account to their Google Account. When a user adds your LINE account as a friend, this workflow automatically sends them a message with a unique authentication link. After the user approves the connection, their Google profile information is fetched, and a confirmation message is sent, completing the loop.\n\n### Prerequisites\n\nBefore you begin, ensure you have the following:\n\n*   **An n8n instance:** Either on n8n.cloud or a self-hosted environment.\n*   **A LINE Developers Account:**\n    *   A Messaging API channel.\n    *   Your Channel Access Token (long-lived).\n*   **A Google Cloud Platform (GCP) Account:**\n    *   A configured OAuth consent screen.\n    *   An OAuth 2.0 Client ID and Client Secret.\n\n### Configuration Overview\n\n1.  **In the LINE Developers Console:**\n    *   Issue and copy your **Channel Access Token**.\n    *   Set the **Webhook URL** to the URL from the `LINE Webhook` node in n8n.\n\n2.  **In the Google Cloud Platform (GCP) Console:**\n    *   Create **OAuth 2.0 Credentials** to get your **Client ID** and **Client Secret**.\n    *   Add the URL from the `Google Auth Callback` node as an **Authorized redirect URI**.\n\n3.  **In n8n:**\n    *   Create two **Header Auth** credentials: one for LINE (with your access token) and one for Google (as a dynamic placeholder).\n    *   Update the placeholder values (`YOUR_GOOGLE_CLIENT_ID`, etc.) in the workflow nodes with your actual credentials.\n    *   Activate the workflows to go live."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1603d558-544b-460a-ab5e-7373891e8b3b",
  "connections": {
    "LINE Webhook": {
      "main": [
        [
          {
            "node": "If Follow Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Follow Event": {
      "main": [
        [
          {
            "node": "Create Google Auth URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Google User Info": {
      "main": [
        [
          {
            "node": "Send Completion Message to LINE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Auth Callback": {
      "main": [
        [
          {
            "node": "Get Google Access Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Google Auth URL": {
      "main": [
        [
          {
            "node": "Send Auth Link to LINE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Auth Link to LINE": {
      "main": [
        []
      ]
    },
    "Get Google Access Token": {
      "main": [
        [
          {
            "node": "Get Google User Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Completion Message to LINE": {
      "main": [
        [
          {
            "node": "Redirect to LINE OA",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow automates the process of linking a new user on your LINE Official Account to their Google Account. When a user adds your LINE account as a friend, this workflow automatically sends them a message with a unique authentication link. After the user approves the…

Source: https://n8n.io/workflows/10950/ — original creator credit. Request a take-down →

More Web Scraping workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Web Scraping

Community Node Disclaimer: This workflow uses KlickTipp community nodes.

Crypto, Custom, N8N Nodes Klicktipp +1
Web Scraping

Automatically sync Fizzy cards to Basecamp todos in real-time. When cards are created, assigned, completed, or reopened in Fizzy, the changes sync instantly to your Basecamp project. Card tags determi

HTTP Request, N8N Nodes Basecamp
Web Scraping

This workflow automates accounts payable: upload a PDF invoice, let Claude AI extract the key fields, and automatically create a vendor bill (incoming invoice) in Odoo 18.

HTTP Request
Web Scraping

This n8n workflow automates airline customer support by classifying travel-related questions, fetching relevant information, generating AI answers, and delivering structured responses to users. It ens

HTTP Request
Web Scraping

This n8n template lets you automatically pull market data for the cryptocurrencies from CoinGecko every hour, calculate custom volatility and market-health metrics, classify each coin’s price action i

HTTP Request