---
title: 為 OpenConnector 建立 HubSpot MCP auth app
description: 建立 HubSpot MCP auth app，設定 OpenConnector redirect URL，並透過 OAuth 連接 HubSpot。
lang: zh-TW
canonical_url: https://oomol.com/zh-tw/docs/openconnector-hubspot-oauth-app/
markdown_url: https://oomol.com/zh-tw/docs/openconnector-hubspot-oauth-app.md
---

# 為 OpenConnector 建立 HubSpot MCP auth app

OpenConnector 目前的 HubSpot provider 使用 HubSpot remote MCP OAuth flow。你需要在 HubSpot 中建立 MCP auth app，複製它的 client ID 和 client secret，然後把這些值儲存到 OpenConnector 的 `hubspot` service。

## OpenConnector service

| Service ID | Provider | Auth type |
| --- | --- | --- |
| `hubspot` | HubSpot remote MCP server | OAuth2 with PKCE |

HubSpot provider 透過 `https://mcp.hubspot.com` 連接。HubSpot 端的權限和帳號授權流程由 MCP auth app 管理。

## 前置條件

- 一個正在運作的 OpenConnector runtime。
- 可以存取 HubSpot Developer Platform 和 MCP Auth Apps 的 HubSpot 帳號。
- 有權限為目標 HubSpot account 建立 MCP auth app。
- 使用者在瀏覽器中開啟的 OpenConnector origin，例如 `http://localhost:3000` 或 `https://connect.example.com`。

## 第 1 步：確定 OpenConnector callback URL

在 OpenConnector origin 後串接 `/oauth/callback`，得到 callback URL。本機測試使用 `http://localhost:3000/oauth/callback`。公開部署時，請先設定 `OOMOL_CONNECT_ORIGIN`，重新啟動 OpenConnector 後使用公開 callback URL，例如 `https://connect.example.com/oauth/callback`。

## 第 2 步：建立 HubSpot MCP auth app

在 HubSpot 中：

1. 開啟要連接的 HubSpot account。
2. 開啟 **Development**。
3. 開啟 **MCP Auth Apps**。
4. 建立新的 MCP auth app。
5. 輸入一個容易辨識的 app name。
6. 將 redirect URL 設定為 OpenConnector 的精確 callback URL。
7. 儲存 app。

HubSpot 官方文件見 [Integrate AI tools with the HubSpot MCP server](https://developers.hubspot.com/docs/apps/developer-platform/build-apps/integrate-with-the-remote-hubspot-mcp-server)。

## 第 3 步：複製 client credentials

從 HubSpot MCP auth app 詳細資料中複製：

| HubSpot 欄位 | OpenConnector 欄位 |
| --- | --- |
| Client ID | `clientId` |
| Client Secret | `clientSecret` |

## 第 4 步：在 OpenConnector 中儲存 HubSpot client

優先使用 OpenConnector Web 主控台：

1. 開啟 OpenConnector Web 主控台，例如 `http://localhost:3000`。
2. 開啟 **Providers**，選擇 **HubSpot**。
3. 點擊 **Configure OAuth Client** 或 **Edit OAuth Client**。
4. 貼上 HubSpot client ID 和 client secret。
5. 點擊 **Save OAuth Client**。

## 第 5 步：連接並測試

儲存 OAuth client 後，在 HubSpot provider 頁面點擊 **Connect**。選擇 HubSpot account，批准存取，回到 OpenConnector，並確認 provider 頁面顯示帳號已連接。

執行 `hubspot.list_properties` 等 CRM action 前，先查看主控台裡的 action 詳細資料。

## 疑難排解建議

| 現象 | 檢查項目 |
| --- | --- |
| HubSpot 提示 client ID 無效 | 使用 MCP auth app 頁面顯示的 Client ID；其他 HubSpot app 類型使用不同的 ID。 |
| Redirect 或 callback 失敗 | HubSpot 中的 redirect URL 必須和 `<openconnector-origin>/oauth/callback` 完全一致。 |
| Token exchange 失敗 | 確認 HubSpot MCP auth app 支援 OAuth with PKCE，並且 OpenConnector 使用的是目前的 HubSpot provider。 |
| 授權到了錯誤的 HubSpot account | 先登出瀏覽器裡的其他 HubSpot 帳號，或使用獨立的瀏覽器 profile 授權。 |
| Action 傳回 permission error | 檢查已連接 HubSpot 使用者權限，以及 HubSpot MCP app 目前的存取規則。 |
