AsyncIO client for the hCaptcha service.
Project description
aiohcaptcha
AsyncIO client for the hCaptcha service
Secure your forms using a captcha.
Install
pip install aiohcaptcha
Usage
Configuration
You can define the secret key HCAPTCHA_SECRET_KEY
in the environment or directly pass it to the HCaptchaClient
model as a parameter.
Get the secret and public keys from the hcaptcha.com.
Template
<div class="h-captcha" data-sitekey="your_site_key"></div>
<script src="https://hcaptcha.com/1/api.js" async defer></script>
Check hCaptcha docs for more details on the HTML widget.
View
from aiohcaptcha import HCaptchaClient
response_token = request.POST["h-captcha-response"]
client = HCaptchaClient(secret_key)
verified = await client.verify(response_token) # a boolean
You can adjust it to any Python Web framework that has async view support.
If you are sending the form data using an AJAX request, use $('textarea[name=h-captcha-response]').val();
for the captcha key.
Response details
Response details are stored in client.response
,
details of the HCaptchaResponse
model is same as the JSON response provided in the hCaptcha documentation.
Extra arguments
You can also add remote_ip
and sitekey
(expected key) to the client.verify
function.
These parameters are explained in the hCaptcha docs.
© 2020 Emin Mastizada. MIT Licenced.
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
Built Distribution
Hashes for aiohcaptcha-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b877e088598d8d65ff32a002c94749746405e4e05ea5234a42e5b26db0b485c |
|
MD5 | 1ae687c4a887205a6e7090daf9279e83 |
|
BLAKE2b-256 | 509a010f596dd32e8cac6beb5430e7914ababa7ef18d904fc3b2cb26f634e778 |