Implement reCAPTCHA with Custom Login Using the REST API

Note: This article is only relevant for self-managed headless projects.

This article explains how to implement reCAPTCHA with member authentication using the REST API.

You'll learn how to:

  • Implement reCAPTCHA using a 3rd party.
  • Use reCAPTCHA tokens during register and login.

Step 1 | Implement reCAPTCHA using a 3rd party

Use a 3rd-party library like Google reCAPTCHA to implement the reCAPTCHA or choose to implement it yourself using Google's APIs.

You can choose to always require reCAPTCHA verification or only require it for suspected bots.

  • To always require reCAPTCHA verification, use a visible site key when loading the reCAPTCHA script.
  • To only require reCAPTCHA verification for suspected bots, use an invisible site key when loading the reCAPTCHA script.

Important

When implementing a reCAPTCHA:

  • Use a Wix site key, not your own, when loading the reCAPTCHA script.
    • Visible site key: '6Ld0J8IcAAAAANyrnxzrRlX1xrrdXsOmsepUYosy'
    • Invisible site key: '6LdoPaUfAAAAAJphvHoUoOob7mx0KDlXyXlgrx5v'
  • Be sure to load the enterprise reCAPTCHA script.

For example, implement a visible reCAPTCHA widget with Google reCAPTCHA:

Copy

Step 2 | Use reCAPTCHA tokens to register or login

Call the Register V2 or Login V2 endpoint with the appropriate reCAPTCHA token returned to your reCAPTCHA implementation.

When always requiring reCAPTCHA verification, send the token using the captcha_tokens.Recaptcha property.

Copy

When only requiring reCAPTCHA verification for suspected bots, send the token using the captcha_tokens.InvisibleRecaptcha property.

Copy
Did this help?