在示範網站中測試 reCAPTCHA

本文說明如何在 Google Cloud上部署示範網站 (已整合 reCAPTCHA 的範例網站),瞭解 reCAPTCHA 的運作方式。

示範網站可協助您執行下列操作:

  • 瞭解使用者對 reCAPTCHA 的體驗。
  • 做為參考,將 reCAPTCHA 整合至您自己的應用程式。
  • 編輯範例應用程式原始碼,嘗試不同的前端和後端做法。

您可以部署下列語言的示範網站:Java、Node.js 或 Python。

每個 Google Cloud 專案一次只能部署一個示範網站。

事前準備

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  2. Enable the reCAPTCHA Enterprise API.

    Enable the API

  3. Make sure that you have the following role or roles on the project: reCAPTCHA Enterprise Admin, reCAPTCHA Enterprise Agent

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      前往「IAM」頁面

    2. 選取專案。
    3. 按一下「授予存取權」
    4. 在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。

    5. 在「Select a role」(選取角色) 清單中,選取角色。
    6. 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
    7. 按一下 [Save]

  4. 如果您先前已部署示範網站,請刪除相關的示範金鑰。

部署示範網站

  1. 前往 Google Cloud 控制台的示範網站頁面。

    前往示範網站

  2. 在「語言」清單中選取語言。

    整個部署程序大約需要 1 分鐘。

  3. 如果出現提示,請授權 Cloud Shell 使用您的憑證發出呼叫。

  4. 如要前往新的試用版「金鑰詳細資料」頁面,請按一下「查看網站」

  5. 如要查看示範網站,請在「Frontend」(前端) 資訊卡中,按一下「View sample web page」(查看範例網頁)

    示範網站會在另一個分頁中開啟。

  6. 如要瞭解將 reCAPTCHA 整合至網站的模式,請點選範例。

  7. 如要變更試用版網站,請按照下列步驟操作:

    1. 在「主要詳細資料」頁面中,按一下「編輯來源」
    2. 在 Cloud Shell 編輯器的「Explorer」中找到所需檔案,然後視需要編輯。

      系統會將儲存的原始碼變更重新載入至示範網站。

    請勿關閉 Cloud Shell 編輯器,否則 Cloud Shell 會關閉,示範網站也會停止運作。

後續步驟