Automate LINE & Google account linking with OAuth2 authentication
DISCOUNT 20%
LINE x Google Account Linking 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 connection, their Google profile information is fetched, and a confirmation message is sent, completing the loop.
Prerequisites
Before you begin, ensure you have the following:
- An n8n instance: Either on n8n.cloud or a self-hosted environment.
- A LINE Developers Account:
- A Messaging API channel.
- Your Channel Access Token (long-lived).
- A Google Cloud Platform (GCP) Account:
- A configured OAuth consent screen.
- An OAuth 2.0 Client ID and Client Secret.
Setup Instructions
Follow these steps to configure the workflow.
Step 1: Configure LINE Developers Console
- Log in to the LINE Developers Console.
- Navigate to your provider and select your Messaging API channel.
- Go to the Messaging API tab.
- Issue a Channel access token (long-lived) and copy the value.
- In the Webhook URL field, paste the Test URL from the
LINE Webhooknode in your n8n workflow. - Enable Use webhook.
Step 2: Configure Google Cloud Platform (GCP)
- Log in to the Google Cloud Console and select your project.
- Navigate to APIs & Services > OAuth consent screen. Configure it if you haven't already, ensuring you add your own Google account as a test user.
- Go to APIs & Services > Credentials.
- Click + CREATE CREDENTIALS and select OAuth 2.0 Client ID.
- For Application type, choose Web application.
- Under Authorized redirect URIs, click + ADD URI and paste the Test URL from the
Google Auth Callbacknode in your n8n workflow. - Click Create. Copy your Client ID and Client Secret.
Step 3: Configure the n8n Workflow
Import the workflow JSON into your n8n canvas and follow these steps to set it up.
1. Configure n8n Credentials
First, set up the credentials that the HTTP Request nodes will use.
For the LINE Messaging API:
- In n8n, go to Credentials > Add credential.
- Search for and select Header Auth.
- Set
NametoAuthorization. - Set
ValuetoBearer YOUR_LINE_CHANNEL_ACCESS_TOKEN(replace with the token from Step 1). - Save the credential with a memorable name like "LINE Messaging API Auth".
For the Google API (Dynamic Token):
- Create another Header Auth credential.
- Set
NametoAuthorization. - For
Value, enter a placeholder likeBearer dummy_token. This will be replaced dynamically by the workflow. - Save the credential with a name like "Google API Dynamic Token".
2. Update Node Parameters
Now, update the parameters in the following nodes:
Create Google Auth URLnode:- In the
valuefield, replaceYOUR_N8N_WEBHOOK_URL_FOR_GOOGLEwith the webhook URL of theGoogle Auth Callbacknode. - Replace
YOUR_GOOGLE_CLIENT_IDwith the Client ID from GCP (Step 2).
- In the
Get Google Access Tokennode:- In the
jsonBodyfield, replaceYOUR_GOOGLE_CLIENT_ID,YOUR_GOOGLE_CLIENT_SECRET, andYOUR_N8N_WEBHOOK_URL_FOR_GOOGLEwith your actual GCP credentials and callback URL.
- In the
Get Google User Infonode:- For Authentication, select
Header Auth. - For Credential for Header Auth, choose the "Google API Dynamic Token" credential you created.
- Important: Click Add Option > Header To Append. Set the
NametoAuthorizationand theValueto the following expression to use the token from the previous step:Bearer {{ $node["Get Google Access Token"].json["access_token"] }}.
- For Authentication, select
Send Auth Link to LINE&Send Completion Message to LINEnodes:- For Credential for Header Auth, choose the "LINE Messaging API Auth" credential.
Redirect to LINE OAnode:- In the
redirectURLparameter, replaceYOUR_LINE_OFFICIAL_ACCOUNT_IDwith your LINE OA's ID (e.g.,@123abcde).
- In the
Step 4: Activate and Test
- Save the workflow by clicking the Save button.
- Activate the workflow using the toggle in the top-right corner.
- On your phone, add your LINE Official Account as a friend. You should receive a message with a link.
- Follow the link to authorize with your Google account. After successful authorization, you should receive a completion message in LINE and be redirected.
> Note: When you are ready for production, remember to replace the "Test" webhook URLs in the LINE and GCP consoles with the "Production" URLs from the n8n webhook nodes.