Guia de início rápido

Instancie o cliente reCAPTCHA Enterprise e faça uma solicitação.

Amostra de código

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);
}

A seguir

Para pesquisar e filtrar exemplos de código de outros produtos do Google Cloud, consulte o navegador de exemplos do Google Cloud.