reCatpcha api v3.0 - with django support
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
crecaptcha-0.1.31.tar.gz
(7.1 kB
view details)
File details
Details for the file crecaptcha-0.1.31.tar.gz.
File metadata
- Download URL: crecaptcha-0.1.31.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94ae70fae0241159ab130bd1d53b4060a558583affd2c7e68cd4db8bcee098e2
|
|
| MD5 |
1fef81c550748339cc45c94a60497891
|
|
| BLAKE2b-256 |
3a0ecb97d5694adc9c7cf0d0b60dc175990b09ae1cf0b3035f488437b7eb975f
|