crecaptcha
A simple python module for Google Recaptcha V3
A pure python module, don't requires requests library
Installation
- from latest version on PyPi:
pip install crecaptcha
how to use?
from crecatpcha.crecaptcha import crecaptcha
SECRET_KEY = 'Your secret key'
def some_function():
response_token = 'the response token from the client'
if crecaptcha(SECRET_KEY, response_token, 'action_name'):
# safe action
pass
else:
# is a bot, take your custom action.
pass
how to use with django?
Configuration:
In the settings.py define the following values:
CRECAPTCHA_SECRET_KEY: the recaptcha secret key.
CRECAPTCHA_KEY_NAME: the name of the var in the POST request, by default is 'recaptcha_token'.
Example:
CRECAPTCHA_SECRET_KEY = "jgjdnvurmfj3nrfo3nrlksjf" # Mandatory
CRECAPTCHA_KEY_NAME = "grecatpcha" # by default is 'recaptcha_token'
Usage:
Simple way:
In the following example if the recaptcha validation fails, it will raise an HttpResponseForbidden
from crecatpcha.django_crecatpcha import crecaptcha
@crecaptcha('login')
def login_user(request):
pass
@crecaptcha('register', threshold=0.6)
def register_user(request):
pass
Advance way:
You can define your custom callback when the validations fails, an optionally you can send args & kwargs.
from crecatpcha.django_crecatpcha import crecaptcha
def register_user_on_crecaptcha_error(request, *args, **kwargs):
pass
@crecaptcha('register', register_user_on_crecaptcha_error, args_on_error=[], kwargs_on_error={})
def register_user(request):
pass
Metadata
Release files for crecaptcha 0.1.32
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| crecaptcha-0.1.32.tar.gz | 7.1 kB | Without provenance | Details |
Release files / crecaptcha-0.1.32.tar.gz
| Download URL | crecaptcha-0.1.32.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
832f84305c26ca2f370f85a0f3a6513a794240a113697a870e08428508d0641d
|
|
BLAKE2b-256 checksum How to use checksums |
dbd84b975cc0b846b5b5ad504539cbb534ef5ee3c161db949a625a8773e5f789
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6
|
Security for crecaptcha 0.1.32
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.