Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 2

Reactjs-Google ReCaptcha v3 'onVerify' method does not trigger for every login click

import React from "react";
import {GoogleReCaptchaProvider, GoogleReCaptcha } from "react-google-recaptcha-v3";

class Login extend React.Component {
   verifyCallback = (response) => {
    // API call to verify the token
   }

    render() {
       return (
          // Here comes a component with email/password and login button
           ....
          <GoogleReCaptchaProvider 
            reCaptchaKey="your-site-key"
            render="explicit">
            <GoogleReCaptcha
                onVerify={this.verifyCallback}
            />
         </GoogleReCaptchaProvider>
       );
   }
}

Here, verifyCallback is triggered when the Google ReCaptcha component is loaded for the first time.

How to trigger verifyCallback for every click of login button?

1 Reply
Highlighted
Copilot Lvl 2
Message 2 of 2

Re: Reactjs-Google ReCaptcha v3 'onVerify' method does not trigger for every login click

Hello @nikithakamath 

 

It seems that you can set the Google recaptcha token with any hidden input in form and then do the validation server side with https://www.google.com/recaptcha/api/siteverify API - please refer https://developers.google.com/recaptcha/docs/verify. That seems to be legitimate way IMO.

 

Would that solve?

 

Thanks.