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.

captchaElemPrefix interfering with invisible reCaptcha execute call

See original GitHub issue

When calling the execute method on the InvisibleReCaptchaComponent, I am getting the following error:

ERROR Error: Invalid site key or not loaded in api.js: ngx_captcha_id_ at Object.Qs [as execute] (recaptcha__en.js:formatted:12496) at InvisibleReCaptchaComponent.push../node_modules/ngx-captcha/fesm5/ngx-captcha.js.InvisibleReCaptchaComponent.execute (ngx-captcha.js:637) at LoginComponent.push../src/app/features/login/login.component.ts.LoginComponent.login (login.component.ts:52)

When stepping into the execute call, I see that it is calling… this.reCaptchaApi.execute(this.captchaElemPrefix); … which is passing in the “ngx_captcha_id_” value as the “optional widget ID” parameter into the Google API.

Upon stepping into the Google API, its throwing an error while attempting to locate the index of this particular reCaptcha widget within whatever “__grecaptcha_cfg.qd” is; in my tests, “qd” always returns an empty object, which then results in Google throwing the above error; ie:


If I force the “captchaElemPrefix” to be undefined, then the Google API falls back to looking for the first widget, and then everything works properly.

By tossing the following “handleLoad” code in place, I’m able to get past this issue:

    handleLoad() {
        (<any>this.captchaElem).captchaElemPrefix = undefined;

However this feels very hacky… I’m wondering if there is some type of init / setup call that is being missed which would properly populate this “qd” object, such that passing in the widget ID would work?

Also note that this is directly reproducible in the demo app (just downloaded it and tried to hit “execute”, ie:


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

Enngagecommented, Jul 17, 2018

Thanks a lot for letting me know & great description! It was indeed a bug caused by me during the last refactor. The execute method should be called with id that is retrieved from Google when creating new captcha. Fix was as easy as to change the method to:

 execute(): void {

Should be fixed in latest release 3.1.2. Thanks again!

samiullahkhalid4commented, Dec 21, 2018

Thank You!

On Fri, Dec 21, 2018 at 8:14 PM Richard Sustek wrote:

This is not the solution. Please be sure to review Google’s documentation on Captcha and setup your site keys & domains correctly. This should be your starting point:

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread .

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 >
javascript - ReCaptcha (Invisible) execute callback is not firing ...
Step A: Calling in the JS Library (I call this as the LAST javascript file, after my common.js file is loaded). <script type="text/javascript" ......
Read more >
data-callback function not working in Invisible reCAPTCHA.
When I click the the submit button the reCAPTCHA will appear and after the verification it doesn't call the callback function. This is...
Read more >
Re: Invisible recaptcha vs visible recaptcha - Marketing Nation
When implement an invisible recaptcha following the method described by Sanford Whiteman​ here, the var recaptchaResponse = grecaptcha.
Read more >
Integrating reCAPTCHA Enterprise with iOS apps
To avoid interference with the application, the set of classes available in the ... Create a button to call reCAPTCHA Enterprise and trigger...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found