question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invisible reCAPTCHA without execute

See original GitHub issue

Sorry if this is a support issue and shouldn’t go here. I have a question about invisible reCAPTCHA.

In your docs, you state

You will also need to invoke the “execute()” method manually. This can be done by either obtaining a reference to RecaptchaComponent via @ViewChild(), or by using inline template reference:

However, my understanding of invisible reCAPTCHA is that calling the execute method manually is a special case, necessary only if you want to explicitly call for the challenge to appear. It is not necessary in the normal course of events. The normal flow is that when the button associated with the reCAPTCHA is pressed, Google decides whether or it seems to be a robot, puts up the challenge if it decides it is, then calls the callback specified as the data-callback attribute if it believes the user is a human or the challenge is passed.

This is how I want things to work. I don’t want to explicitly call for the challenge to appear, and I don’t think I need or want to call execute. I tried that, and as I suspected, the challenge came up every time, which is definitely not what I want. . I just want resolve to be called when Google thinks things are OK. Does the component support that, and if so please help me understand how, since I am too dense to figure it out myself.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jpinxtencommented, Feb 27, 2018

@kostadin-dimitrov Here is some working code:

@ViewChild('captchaRef') captchaRef: RecaptchaComponent;

executeReCaptcha() {
    this.captchaRef.execute();
}

getReCaptchaResponse(response: string) {
    this.someForm.patchValue({
        'g-recaptcha-response': response
    });
    // Submit your form
}

<form [formGroup]="someForm" (ngSubmit)="executeReCaptcha()">
    <re-captcha 
    #captchaRef siteKey="{{recaptchaPublicKey}}"
    (resolved)="getReCaptchaResponse($event)" size="invisible">
    </re-captcha>

    <button type="submit">Submit</button>
</form>
1reaction
Manipuloscommented, Mar 16, 2018

I had the same problem with “Cannot contact reCAPTCHA. Check your connection and try again.”

but i fixed it by resetting on login failed

onSubmit(){

if (this.loginForm.valid) {
this.errorMessage= "";

 this.authServiceSubscription = this.authService.loginSponsorUser(this.loginForm.value).subscribe(loginResult=>{
   console.log("Sponsor login success");
   this.authService.changeSponsorUserStatusToAuthenticated();
   this.router.navigate(['/sponsors/dashboard']);

 },(err)=>{
    console.log("There was an error login in",err.error);
    this.errorMessage = "Hubo un error en el login: "+err.error;
    this.captchaRef.reset();
 });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Invisible reCAPTCHA - Google Developers
To invoke the invisible reCAPTCHA, you can either: Automatically bind the challenge to ... Call grecaptcha.execute from a javascript method.
Read more >
Quick Guide: How to Put Invisible reCaptcha on Your Website
This gives you perfect freedom on the order in which you decide to run functions. For example, you can call one of your...
Read more >
How to integrate Invisible reCaptcha to a website, without a form
I recently posted an answer detailing how to programmatically render and trigger invisible recaptcha for ajax forms.
Read more >
What is invisible reCAPTCHA? How to choose the right type of ...
Unlike the No CAPTCHA reCAPTCHA checkbox, the invisible reCAPTCHA is only a badge like this: With this invisible reCAPTCHA, no user interaction ...
Read more >
Google reCAPTCHA V2 Invisible | Branch CMS Documentation
The invisible reCAPTCHA badge does not require the user to click on a checkbox. Instead, it is invoked directly when the user clicks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found