3

I'm trying to use google ReCaptcha enterprise in my rails project, but I'm getting this error:

{"error"=>{"code"=>403, "message"=>"The provided cloud project number does not own the given recaptcha key", "status"=>"PERMISSION_DENIED"}}

What I have:

  • My project ID, I got from the list of the project under the ID column
  • reCAPTCHA Key (site key) and domains created in reCAPTCHA Enterprise panel
  • An API Key created here. Application restrictions: none, API restrictions: reCAPTCHA Enterprise API

I'm posting data to this endpoint:

https://recaptchaenterprise.googleapis.com/v1beta1/projects/#{project_id}/assessments?key=#{API_key}

and the body of the request is:

{
    event:
    {
        token: response_token,
        siteKey: site_key,
        userIpAddress: domain
    }
}
Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
Zakaria
  • 983
  • 15
  • 24
  • Did you create `Service Account` with Role reCAPTCHA Enterprise Agent? How are you authentication your SA, like in [this documentation](https://cloud.google.com/recaptcha-enterprise/docs/install-on-gcp#creating-a-service-account-for-backend-authentication) – PjoterS Dec 06 '21 at 12:25
  • @PjoterS `Service Account` is not my case. I used the reCAPTCHA Enterprise API like in https://cloud.google.com/recaptcha-enterprise/docs/authenticate-apis – Zakaria Dec 07 '21 at 06:03
  • 1
    You mention that you took projectID from under ID Column. It's only one project ID or there are more? Can you confirm that you are using reCAPTCHA Key in the same project it was created? Could you share details how did you create it? The only thing that comes to my mind is that reCaptcha key was created in a different project than requested in API call or typo during creating this key. – PjoterS Dec 07 '21 at 12:04
  • 1
    You're right, I was using the v3 site key on the client-side, which means the response_token was wrong. I forgot to update the client-side by enterprise key. thanks man, it works now @PjoterS – Zakaria Dec 08 '21 at 07:59

1 Answers1

3

As OP confirmed in the comment section, the root cause of the issue was with wrong enterprise key.

You're right, I was using the v3 site key on the client-side, which means the response_token was wrong. I forgot to update the client-side by enterprise key. thanks man, it works now

Error The provided cloud project number does not own the given recaptcha key indicates that there is a mismatch with the key. When OP updated the client-side key it started to work.

PjoterS
  • 12,841
  • 1
  • 22
  • 54
  • 2
    Hi @WytrzymałyWiktor. yes, using the enterprise key instead of the V3 site key in the client-side app solved my problem. – Zakaria Dec 09 '21 at 10:09