取得 API 金鑰
API 金鑰用於驗證你對群組GM API 的存取權限。每把金鑰都有獨立的權限設定。
建立 API 金鑰
Section titled “建立 API 金鑰”步驟 1:登入 Dashboard
Section titled “步驟 1:登入 Dashboard”前往 Dashboard 並使用 LINE 帳號登入。
步驟 2:進入 API 金鑰頁面
Section titled “步驟 2:進入 API 金鑰頁面”點擊側邊選單的「設定」>「API 金鑰」。
步驟 3:建立新金鑰
Section titled “步驟 3:建立新金鑰”- 點擊「新增金鑰」按鈕
- 輸入金鑰名稱(例如:
Production API) - 選擇需要的權限
- 點擊「建立」
步驟 4:複製金鑰
Section titled “步驟 4:複製金鑰”金鑰格式:gm_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| 權限 | 說明 | 可存取的 API |
|---|---|---|
read:messages | 讀取訊息 | 訊息備份、搜尋 |
read:members | 讀取成員 | 成員列表、分析 |
read:media | 讀取媒體 | 圖片、影片、檔案 |
write:assistant | 設定助理 | 自動回覆、歡迎訊息、規則 |
依用途分開金鑰
Section titled “依用途分開金鑰”Production API → read:messages, read:membersAnalytics Service → read:messages, read:membersBackup Worker → read:messages, read:media定期輪換金鑰
Section titled “定期輪換金鑰”建議每 90 天更換一次金鑰,步驟:
- 建立新金鑰
- 更新應用程式設定
- 確認新金鑰正常運作
- 刪除舊金鑰
# 使用環境變數export GROUPGM_API_KEY="gm_xxxxx"
# 不要寫死在程式碼中# ❌ 錯誤做法api_key = "gm_xxxxx"
# ✅ 正確做法api_key = os.environ.get("GROUPGM_API_KEY")在 Dashboard 可以查看每把金鑰的:
- 今日請求次數
- 本月請求次數
- 最後使用時間
- 找到要刪除的金鑰
- 點擊刪除按鈕
- 確認刪除
取得金鑰後,前往發送第一個請求測試連線。