Bassel Turky
Bassel Turky

Reputation: 511

Error: 7 PERMISSION_DENIED: Permission 'recaptchaenterprise.assessments.create' denied on resource

I keep getting this error, I am trying to implement google reCaptcha v3, I gave myself all possible permissions on my service account but nothing seems to work. I don't even understand the error.

these are some lines of the error from the terminal.

Error: 7 PERMISSION_DENIED: Permission 'recaptchaenterprise.assessments.create' denied on resource '//cloudresourcemanager.googleapis.com/projects/my-project-auth-330511' (or it may not exist)

...\node_modules@grpc\grpc-js\build\src\call.js:31 return Object.assign(new Error(message), status);

statusDetails: [
    ErrorInfo {
      metadata: {
        permission: 'recaptchaenterprise.assessments.create',
        resource: 'projects/my-project-auth-330511'
      },
      reason: 'IAM_PERMISSION_DENIED',
      domain: 'cloudresourcemanager.googleapis.com'
    }
  ],
  reason: 'IAM_PERMISSION_DENIED',
  domain: 'cloudresourcemanager.googleapis.com',

I would like to know what causes this error.

Upvotes: 9

Views: 5816

Answers (2)

andreszs
andreszs

Reputation: 2956

Or you can use an API key instead of service accounts as follows:

  1. Open the Google Cloud Console and navigate to the project where you want to enable API keys for reCAPTCHA Enterprise.
  2. In the navigation menu on the left side of the console, click on "APIs & Services".
  3. Click on the "Enable APIs and Services" button.
  4. In the search bar, type "Recaptcha Enterprise" and press Enter.
  5. Locate the reCAPTCHA Enterprise API and click the toggle switch to enable it.
  6. Click on "Credentials" in the left navigation menu under the "APIs & Services" section.
  7. Click on "Create credentials" and then select "API key". Give your API key a descriptive name and click "Create". Configure any necessary restrictions for the API key. You can restrict access based on IP addresses or referrers for increased security.

Then simply append the API key generated into your assessment POST request as follows:

https://recaptchaenterprise.googleapis.com/v1/projects/{{PROJECT_ID}}/assessments?key={{API_KEY}}

along with the JSON body as explained in Create assessments for mobile applications.

enter image description here

Upvotes: 0

Fokin Evgenii
Fokin Evgenii

Reputation: 91

You should create a service account at credentials page.

Then, give reCaptcha Enterprise Agent role on creation (we did not manage to add roles to existing service-account).

Upvotes: 9

Related Questions