0

我确实在https://googleapis.dev/ruby/google-cloud-recaptcha_enterprise-v1/latest/index.html上关注了他们的文档

我首先添加了环境变量RECAPTCHA_ENTERPRISE_CREDENTIALS,然后运行

client = ::Google::Cloud::RecaptchaEnterprise::V1::RecaptchaEnterpriseService::Client.new

文档说response = client.create_assessment request,但文档没有添加示例请求,所以我确实假设它看起来像本文档https://cloud.google.com/recaptcha-enterprise/docs/create-assessment

{
  "event": {
    "token": "token",
    "siteKey": "key"
  }
}

但是当我执行时client.create_assessment它给了我错误ArgumentError: Unknown field name 'event' in initialization map entry.

我还尝试遵循此https://googleapis.dev/ruby/google-cloud-recaptcha_enterprise-v1/latest/Google/Cloud/RecaptchaEnterprise/V1/RecaptchaEnterpriseService/Client.html#create_assessment-instance_method ,其中参数是请求以及给我错误ArgumentError: Unknown field name 'request' in initialization map entry.

创建评估的正确参数/请求可能是什么?

我使用的宝石是google-cloud-recaptcha_enterprise-v1google-cloud-recaptcha_enterprise

4

1 回答 1

1

所以我通过使用client.create_assessment(parent: "projects/{your project-id}", assessment: event) 我的事件值来解决这个问题event = Google::Cloud::RecaptchaEnterprise::V1::Event.new(token: "token from execute", site_key: "your site key")

它解决了错误并回答了问题(但发生此错误之后的另一个错误是关于权限被拒绝)。解决后我会更新。

于 2021-02-23T21:05:32.377 回答