iT邦幫忙

2025 iThome 鐵人賽

DAY 8
0
DevOps

Mac 環境 n8n 30 天學習計畫系列 第 8

Day 8 任務:用 n8n 讀取 Google Sheets📂

  • 分享至 

  • xImage
  •  

Step 1:Google Cloud 建專案

  1. 打開 Google Cloud Console
  2. 點「選取專案」 → 建立一個新專案,例如叫 n8n-demo
  3. 之後所有設定(API、憑證)都在這個專案裡。

Step 2:啟用 Google Sheets API

  1. 在專案內 → 左上選單 APIs & Services → Library
  2. 搜尋 Google Sheets API → 按啟用。
  3. 建議同時啟用 Google Drive API(讓 n8n 列出你的檔案)。
    https://ithelp.ithome.com.tw/upload/images/20250920/20169144wzQM5IqDtx.png

https://ithelp.ithome.com.tw/upload/images/20250920/20169144X267ttQiQC.png

Step 3:設定 OAuth Consent Screen

  1. APIs & Services → OAuth consent screen
  2. User type:選 External(一般個人帳號用這個)。
  3. 填:
    • App name:隨便填,例如 n8n Sheets Test
    • Support email:你的 Gmail
    • Developer contact email:一樣 Gmail

https://ithelp.ithome.com.tw/upload/images/20250920/20169144PejbC6mlx5.png


Step 4:建立 OAuth Client ID

  1. APIs & Services → Credentials → Create Credentials → OAuth client ID

  2. 類型選 Web application

  3. 在「Authorized redirect URIs」加上 n8n 提供的網址,例如:

    http://localhost:5678/rest/oauth2-credential/callback
    
  4. 按 Create → 會拿到 Client IDClient Secret
    https://ithelp.ithome.com.tw/upload/images/20250920/20169144slpEcDBIY1.png


Step 5:在 n8n 建立憑證

  1. 打開 n8n → 左側 Credentials → 新增 → 搜尋 Google Sheets

  2. 選擇 Google OAuth2 API(有些版本是直接叫 Google Sheets API

  3. 貼上 Client ID / Secret

  4. Scope:輸入

     https://www.googleapis.com/auth/drive.file
     https://www.googleapis.com/auth/spreadsheets
     https://www.googleapis.com/auth/drive.metadata
    
  5. Sign in with Google → 出現 Google 授權畫面 → 登入並同意

  6. 成功後,n8n 就存好憑證了。
    https://ithelp.ithome.com.tw/upload/images/20250920/20169144Pqm7KvV3RQ.png


Step 6:建立 Workflow 測試

  1. 新建一個 Workflow:
    Cron → Google Sheets → Console
  2. Cron:先設直接手動
  3. Google Sheets Node:
    • Credential:選剛建好的
    • Operation:Get Many
    • Document:用 By URL → 貼上你的試算表網址
      http://localhost:5678/rest/oauth2-credential/callback
    • Sheet:選工作表名稱(通常是 Sheet1
    • Range:可以留空,或填 A1:C10
      https://ithelp.ithome.com.tw/upload/images/20250920/20169144k48PaA1sl1.png
  4. 接一個 Console Node,輸出結果。
  5. 點「Execute Workflow」測試。
    https://ithelp.ithome.com.tw/upload/images/20250920/20169144lqyWZ5sdq8.png

上一篇
Day7: Email 節點串接 —自動寄信給自己📩
系列文
Mac 環境 n8n 30 天學習計畫8
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言