# Why is there no captcha option for the login method in auth0.js?

**URL:** <https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [February 14, 2023, 11:34pm UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517 "2023-02-14T23:34:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wat\_01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wat\_01](https://community.auth0.com/u/wat_01)\
**Post date:** [February 14, 2023, 11:34pm UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/1 "2023-02-14T23:34:51Z")

</div>

I am currently using auth0.js in react to create a universal login page.  
I needed to use captcha for that, but I couldn’t find the captcha option in the login method. I am wondering how I should implement this.  
I have looked at the following information, but could not understand it well.

> [@Auth0.js 9.14.0 captcha?](https://community.auth0.com/t/auth0-js-9-14-0-captcha/52743):
>
> when i try to create Universal Login custom Page using auth0.js, i found param captcha. auth0.js 9.14.0 needs captcha.getValue() this param is what? div ~class=captcha-container~ tag display CAPTCHA that is set by [anormaly detection → bot detection → simple captcha] ?? [https://auth0.com/docs/libraries/auth0js#webauth-login-](https://auth0.com/docs/libraries/auth0js#webauth-login-) this docment is not written about this param “captcha”… webAuth.login({ realm: databaseConnection, email: email, password: password, cap…

---

<div class="post-metadata">

**Author:** ![wayne.lim](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wayne.lim/32/44587_2.png) [@wayne.lim](https://community.auth0.com/u/wayne.lim)\
**Post date:** [February 15, 2023, 6:51am UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/2 "2023-02-15T06:51:10Z")

</div>

Hello @wat_01 ,

Welcome to the Community!

To [enable Captcha](https://auth0.com/docs/secure/attack-protection/bot-detection), you can configure it from the dashboard. You can enable from your dashboard: Security \> Attack Protection \> Bot Detection

With regards to the post, you can use the captcha parameter in the login method after you instantiate a variable with [renderCaptcha](https://auth0.github.io/auth0.js/WebAuth.html#renderCaptcha).

Thanks!

---

<div class="post-metadata">

**Author:** ![wat\_01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wat\_01](https://community.auth0.com/u/wat_01)\
**Post date:** [February 15, 2023, 7:11am UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/3 "2023-02-15T07:11:34Z")

</div>

@wayne.lim  
Thanks for the reply!  
I am using @types/auth0.js and when I look at the types I get a type error with no captcha option.

> <https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/auth0-js/index.d.ts#L881-L896>

So how do I pass the captcha option to the login method?

This is part of the code.

```typescript
const loginWithUsernamePassword = useCallback(
  (username: string, password: string) => {
    const urlParams = new URLSearchParams(window.location.search);
    const stateParam = urlParams.get("state") || "";
    const databaseConnection = "Username-Password-Authentication";

    try {
      webAuth.login(
        {
          username,
          password,
          realm: databaseConnection,
          state: stateParam,
        },
        (auth0Error, result) => {
          if (auth0Error) {
            throw Error(auth0Error.error);
          }
        }
      );
    } catch (error) {
      captureException(error);
    }
  },
  [webAuth]
);

```

---

<div class="post-metadata">

**Author:** ![wat\_01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wat\_01](https://community.auth0.com/u/wat_01)\
**Post date:** [February 15, 2023, 11:07pm UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/4 "2023-02-15T23:07:22Z")

</div>

@wayne.lim  
Should I add the above captcha option to DefinitelyTyped?

---

<div class="post-metadata">

**Author:** ![wayne.lim](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wayne.lim/32/44587_2.png) [@wayne.lim](https://community.auth0.com/u/wayne.lim)\
**Post date:** [February 16, 2023, 7:01am UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/5 "2023-02-16T07:01:04Z")

</div>

Hello @wat_01 ,

Thank you for sending the repo over.  
It seems like DefinitelyTyped has type definitions up to Auth0js `9.14` and no captcha options in CrossOriginLoginOptions which explains the type error you received.

To [add Bot Detection Captcha](https://auth0.com/docs/secure/attack-protection/bot-detection/bot-detection-custom-login-pages#customize-the-login-form), you need to use version `9.16` or higher of the auth0.js library. You can also refer to the [flow limitations](https://auth0.com/docs/secure/attack-protection/bot-detection#flow-limitations) for Bot Protection.

Would it possible for you to customise Login Page from the Dashboard? Navigate to Branding \> Universal Login \> scroll down to Advanced Options \> Select Classic \> Login Tab \> Tick Customise Login \> from dropdown, select Custom Login Form. You will be able to configure your captcha from there.

Thanks!

---

<div class="post-metadata">

**Author:** ![wat\_01](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@wat\_01](https://community.auth0.com/u/wat_01)\
**Post date:** [February 16, 2023, 7:16am UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/6 "2023-02-16T07:16:34Z")

</div>

@wayne.lim  
Thanks for the reply！  
So I am going to send myself a PR to add the captcha option, is that ok?

Just add the captcha option to the following.

> <https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/auth0-js/index.d.ts#L881-L896>

Currently, I am using the following version.

@types/auth0-js: ^9.14.7  
auth0-js: ^9.20.1

I am curious about one more point. Why is there no notation about the captcha option here?  
[https://auth0.com/docs/libraries/auth0js#webauth-login-](https://auth0.com/docs/libraries/auth0js#webauth-login-)

---

<div class="post-metadata">

**Author:** ![jacek.szczesny](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jacek.szczesny](https://community.auth0.com/u/jacek.szczesny)\
**Post date:** [September 21, 2023, 2:16pm UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/7 "2023-09-21T14:16:51Z")

</div>

Hi,  
you can extend CrossOriginLoginOptions by adding missing ‘captcha’ parameter:

 ![Screenshot 2023-09-21 at 16.18.42](https://global.discourse-cdn.com/auth0/original/3X/7/7/77a698113a73f7e82282499c4e7e5d82f42f1497.png)

and pass the object of new type to login() function:

 ![Screenshot 2023-09-21 at 16.21.18](https://global.discourse-cdn.com/auth0/original/3X/c/7/c753705d5d3168b8d77a798be05818c3e50c87e8.png)

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 6, 2024, 12:24am UTC](https://community.auth0.com/t/why-is-there-no-captcha-option-for-the-login-method-in-auth0-js/100517/8 "2024-12-06T00:24:43Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
