google-recaptcha

WebJar for google-recaptcha

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

google-recaptcha
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

google-recaptcha
WebJar for google-recaptcha
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/martin-experiments/google-recaptcha

Download google-recaptcha

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/google-recaptcha/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>google-recaptcha</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/google-recaptcha/
implementation 'org.webjars.npm:google-recaptcha:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/google-recaptcha/
implementation ("org.webjars.npm:google-recaptcha:1.1.0")
'org.webjars.npm:google-recaptcha:jar:1.1.0'
<dependency org="org.webjars.npm" name="google-recaptcha" rev="1.1.0">
  <artifact name="google-recaptcha" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='google-recaptcha', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "google-recaptcha" % "1.1.0"
[org.webjars.npm/google-recaptcha "1.1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : debug jar [2.2.0,3)
org.webjars.npm : request jar [2.74.0,3)

Project Modules

There are no modules declared in this project.

Google Recaptcha

Build Status Codacy Badge Codacy Badge

A simple and framework agnostic way to verify Google Recaptcha data. This package currently supports Google Recaptcha V2.

Installation

$ yarn add google-recaptcha

Usage

const GoogleRecaptcha = require('google-recaptcha')

const googleRecaptcha = new GoogleRecaptcha({secret: 'RECAPTCHA_SECRET_KEY'})

// Some pseudo server code:

http.on('POST', (request, response) => {
  const recaptchaResponse = request.body['g-recaptcha-response']

  googleRecaptcha.verify({response: recaptchaResponse}, (error) => {
    if (error) {
      return response.send({isHuman: false})
    }

    return response.send({isHuman: true})
  })
})

Methods and Variables

constructor(Object options)

Creates an instance of the Google Recaptcha verifier. Here are the options:

  • String secret (required): Your Google Recaptcha secret key.
  • String apiUrl: The API URL to verify with. This option defaults to GoogleRecaptcha.DEFAULT_API_URL.
  • Object logger: Any console.log compatible logger. Defaults to using the debug package. The debug namespace is recaptcha.

googleRecaptcha.verify(Object options, Function callback)

Runs a verification of the Recaptcha response. Here are the options:

  • String response (required): The Recaptcha response token.
  • String remoteIp: The user's IP address.

The callback can take an Error error as its first parameter and a Object body as its second parameter. The body is a raw response from the Recaptcha verification. Specific details can be found here.

Static String GoogleRecaptcha.DEFAULT_API_URL

The default API URL to verify with. The value is https://www.google.com/recaptcha/api/siteverify.

License

Copyright (c) 2016 Martin Experiments LLC

MIT (http://www.opensource.org/licenses/mit-license.php)

Versions

Version
1.1.0