在演示网站中测试 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.
Enable the reCAPTCHA Enterprise API.
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 - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
如果您之前部署过演示网站,请删除相关的演示密钥。
-
部署演示网站
在 Google Cloud 控制台中,前往演示网站页面。
在语言列表中,选择一种语言。
整个部署过程可能需要大约 1 分钟。
如果系统提示,请授权 Cloud Shell 使用您的凭据进行调用。
如需前往新的演示版关键详情页面,请点击查看网站。
如需查看演示网站,请在 Frontend 卡片中点击 View sample web page。
演示网站会在单独的标签页中打开。
如需了解将 reCAPTCHA 与网站集成的模式,请点击示例。
如果您想更改演示网站,请执行以下操作:
- 在密钥详情页面中,点击修改来源。
在 Cloud Shell 编辑器中,在浏览器中找到所需文件,并根据需要进行修改。
对源代码所做的已保存更改会重新加载到演示网站中。
请勿关闭 Cloud Shell Editor,因为这会关闭 Cloud Shell 并停止演示网站。