You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

google-recaptcha-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-recaptcha-api

A simple library of captcha based on Google reCAPTCHA Server API that supports Node.js.

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

google-recaptcha-api

A simple library of captcha based on Google reCAPTCHA Server API that supports Node.js.

Install

Using npm

npm install google-recaptcha-api --save

Usage

Node.js usage

You can use google-recaptcha-v2 in browser.

const GoogleReCaptcha = require('google-recaptcha-api');
const captcha = new GoogleReCaptcha('your_server_captcha_key');
try {
    const res = await captcha.validate('captcha_token', 'user_ip');
    if (res.success) {
        //The response token is valid.
    } else {
        //The response token is invalid.
    }
} catch(e) {
    //Some exception, such as network error => request timeout.
}

You can get server_captcha_key from Google reCAPTCHA Admin Console.

Method

new GoogleReCaptcha(secret, host) => Create an instance of google-recaptcha-api.

  • secret => required, the shared key between your site and reCAPTCHA.
  • host => optional, API hostname, default value is www.google.com. Specially, some areas require network proxying, such as China, just set www.recaptcha.net.

instance.validate(response, remoteip) => Using the following API to ensure the response token is valid. Return value is a promise, you can use async-await synchronizing code.

  • response => required, the user response token provided by the reCAPTCHA client-side integration on your site.
  • remoteip => required, the user's IP address.

License

google-recaptcha-api is MIT licensed.

Keywords

captcha

FAQs

Package last updated on 10 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts