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.
For unit testing, you can create the Client HCaptchaClient with debug=True parameter.
In this mode, the verify function will return True if the user_response token and sitekey parameters do match, otherwise it will return False:
client = HCaptchaClient("<SECRET_KEY>", debug=True)
assert await client.verify("<USER_TOKEN>", sitekey="<SAME_TOKEN>")
assert await client.verify("<USER_TOKEN>", sitekey="<DIFFERENT_TOKEN>") is False
© 2020 Emin Mastizada. MIT Licenced.
Metadata
Release files for aiohcaptcha 0.1.2
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 | |
|---|---|---|---|---|
| aiohcaptcha-0.1.2.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohcaptcha-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.5 kB
Release files / aiohcaptcha-0.1.2.tar.gz
| Download URL | aiohcaptcha-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed1fa0cee963b5678145b1881de082445c0b6047a58d031855b41f38f37a07ea
|
|
BLAKE2b-256 checksum How to use checksums |
6ebc3ca08e718e042316bf8c3428a16a7971944f33490dd934694dcf9f7879b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.6 Linux/5.9.2-arch1-1
|
Release files / aiohcaptcha-0.1.2-py3-none-any.whl
| Download URL | aiohcaptcha-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7baa58ed3207bad52fb6bc61ccc4e4929cde5c6739bfc26dd385d0637355467
|
|
BLAKE2b-256 checksum How to use checksums |
16f236fd3078175aefc481279f73fd5f66bdcc97be30e4978a7879600dd2ad4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.6 Linux/5.9.2-arch1-1
|
Security for aiohcaptcha 0.1.2
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.