在示範網站中測試 reCAPTCHA
本文說明如何在 Google Cloud上部署示範網站 (已整合 reCAPTCHA 的範例網站),瞭解 reCAPTCHA 的運作方式。
示範網站可協助您執行下列操作:
- 瞭解使用者對 reCAPTCHA 的體驗。
- 做為參考,將 reCAPTCHA 整合至您自己的應用程式。
- 編輯範例應用程式原始碼,嘗試不同的前端和後端做法。
您可以部署下列語言的示範網站:Java、Node.js 或 Python。
每個 Google Cloud 專案一次只能部署一個示範網站。
事前準備
- In the Google Cloud console, on the project selector page, select or create a Google Cloud project. - Roles required to select or create a project - Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- 
      Create a project: To create a project, you need the Project Creator
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 
- Enable the reCAPTCHA Enterprise API. - Roles required to enable APIs - To enable APIs, you need the Service Usage Admin IAM role ( - roles/serviceusage.serviceUsageAdmin), which contains the- serviceusage.services.enablepermission. Learn how to grant roles.
- Make sure that you have the following role or roles on the project: reCAPTCHA Enterprise Admin, reCAPTCHA Enterprise Agent - Check for the roles- 
              In the Google Cloud console, go to the IAM page. Go to IAM
- Select the project.
- 
              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. 
- 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- 
              In the Google Cloud console, go to the IAM page. 前往 IAM
- 選取專案。
- 按一下 「授予存取權」。
- 
              在「New principals」(新增主體) 欄位中,輸入您的使用者 ID。 這通常是 Google 帳戶的電子郵件地址。 
- 在「Select a role」(選取角色) 清單中,選取角色。
- 如要授予其他角色,請按一下 「新增其他角色」,然後新增每個其他角色。
- 按一下 [Save]。
 - 如果您先前已部署示範網站,請刪除相關的示範金鑰。 
- 
              
部署示範網站
- 前往 Google Cloud 控制台的示範網站頁面。 
- 在「語言」清單中選取語言。 - 整個部署程序大約需要 1 分鐘。 
- 如果出現提示,請授權 Cloud Shell 使用您的憑證發出呼叫。 
- 如要前往新的試用版「金鑰詳細資料」頁面,請按一下「查看網站」。 
- 如要查看示範網站,請在「前端」資訊卡中,按一下「查看範例網頁」。 - 示範網站會在另一個分頁中開啟。 
- 如要瞭解將 reCAPTCHA 與網站整合的模式,請點選範例。 
- 如要變更試用版網站,請按照下列步驟操作: - 在「主要詳細資料」頁面中,按一下「編輯來源」。
- 在 Cloud Shell 編輯器的「Explorer」中找到所需檔案,然後視需要編輯。 - 系統會將儲存的原始碼變更重新載入至示範網站。 
 - 請勿關閉 Cloud Shell 編輯器,否則 Cloud Shell 會關閉,示範網站也會停止運作。