Schnellstart

Instanziieren Sie den reCAPTCHA Enterprise-Client und stellen Sie eine Anfrage.

Codebeispiel

Node.js

/**
 * Instantiate the reCAPTCHA Enterprise client and make request.
 * @param {string} projectNumber The project number to use when making requests.
 */
async function main(projectNumber) {
  // Create the reCAPTCHA client library.
  const {
    RecaptchaEnterpriseServiceClient,
  } = require('@google-cloud/recaptcha-enterprise');
  const client = new RecaptchaEnterpriseServiceClient();

  // format the path to the project (it should be prefaced with projects/).
  const formattedParent = client.projectPath(projectNumber);
  // assessment should contain event with RESPONSE_TOKEN and RECAPTCHA_SITE_KEY:
  // "{'event': {'token': 'RESPONSE_TOKEN', 'siteKey': 'RECAPTCHA_SITE_KEY'}}"
  const assessment = {};

  const request = {
    parent: formattedParent,
    assessment: assessment,
  };

  await client.createAssessment(request);
}

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.