# google-recaptcha-v2
A Reflex custom component google-recaptcha-v2.
## Installation
```bash
pip install reflex-google-recaptcha-v2
```
## Usage
Set your site key and secret key in your environment variables.
```bash
export RECAPTCHA_SITE_KEY="your-site-key"
export RECAPTCHA_SECRET_KEY="your-secret-key"
```
Alternatively, you can set the keys via python functions as seen in the demo app.
### Place the Recaptcha component
```python
import reflex as rx
from reflex_google_recaptcha_v2 import google_recaptcha_v2
def index():
return rx.vstack(
...,
google_recaptcha_v2(),
)
```
### Verify the Recaptcha response
Before taking actions on the backend, you should verify that the user
browser has passed validation of the token.
This value will be set for the specific tab that has completed validation and
persists for the lifetime of the Reflex session (until the tab is closed).
```python
import reflex as rx
from reflex_google_recaptcha_v2 import GoogleRecaptchaV2State
class MyState(rx.State):
form_error: str
async def handle_submit(self, form_data):
...
recaptcha_state = await self.get_state(GoogleRecaptchaV2State)
if not recaptcha_state.token_is_valid:
self.form_error = "Invalid recaptcha. Are you a robot?"
return
```
Raw data
{
"_id": null,
"home_page": null,
"name": "reflex-google-recaptcha-v2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "reflex, reflex-custom-components",
"author": null,
"author_email": "Masen Furer <m_github@0x26.net>",
"download_url": "https://files.pythonhosted.org/packages/24/9a/55fff79cbc2a8ceaf5b1f8799ac14da21c39c5678a255bf11336bd3556dd/reflex_google_recaptcha_v2-0.0.4.tar.gz",
"platform": null,
"description": "# google-recaptcha-v2\n\nA Reflex custom component google-recaptcha-v2.\n\n## Installation\n\n```bash\npip install reflex-google-recaptcha-v2\n```\n\n## Usage\n\nSet your site key and secret key in your environment variables.\n\n```bash\nexport RECAPTCHA_SITE_KEY=\"your-site-key\"\nexport RECAPTCHA_SECRET_KEY=\"your-secret-key\"\n```\n\nAlternatively, you can set the keys via python functions as seen in the demo app.\n\n### Place the Recaptcha component\n\n```python\nimport reflex as rx\n\nfrom reflex_google_recaptcha_v2 import google_recaptcha_v2\n\ndef index():\n return rx.vstack(\n ...,\n google_recaptcha_v2(),\n )\n```\n\n### Verify the Recaptcha response\n\nBefore taking actions on the backend, you should verify that the user\nbrowser has passed validation of the token.\n\nThis value will be set for the specific tab that has completed validation and\npersists for the lifetime of the Reflex session (until the tab is closed).\n\n```python\nimport reflex as rx\n\nfrom reflex_google_recaptcha_v2 import GoogleRecaptchaV2State\n\n\nclass MyState(rx.State):\n form_error: str\n\n async def handle_submit(self, form_data):\n ...\n recaptcha_state = await self.get_state(GoogleRecaptchaV2State)\n if not recaptcha_state.token_is_valid:\n self.form_error = \"Invalid recaptcha. Are you a robot?\"\n return\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Google ReCAPTCHA v2 Integration",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/masenf/reflex-google-recaptcha-v2"
},
"split_keywords": [
"reflex",
" reflex-custom-components"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c8d35e0ab0ec550c0c5176cd2c13e02c6554be17f1257b2edb87741be45cda01",
"md5": "7d5e77d6321fa91181c1c896cfc6030b",
"sha256": "991d9e06502ca694bd288d6f564025cec77747bc6601aee6a0f809618365817b"
},
"downloads": -1,
"filename": "reflex_google_recaptcha_v2-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7d5e77d6321fa91181c1c896cfc6030b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4424,
"upload_time": "2024-09-19T18:04:51",
"upload_time_iso_8601": "2024-09-19T18:04:51.167701Z",
"url": "https://files.pythonhosted.org/packages/c8/d3/5e0ab0ec550c0c5176cd2c13e02c6554be17f1257b2edb87741be45cda01/reflex_google_recaptcha_v2-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "249a55fff79cbc2a8ceaf5b1f8799ac14da21c39c5678a255bf11336bd3556dd",
"md5": "9d9f3226f876114fdc15ff9564aacdd1",
"sha256": "b7fbc85051cf6cbe3ff8b29ee754a7d6738030c17ce8b7bb75bb9912c3b355d2"
},
"downloads": -1,
"filename": "reflex_google_recaptcha_v2-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "9d9f3226f876114fdc15ff9564aacdd1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 3964,
"upload_time": "2024-09-19T18:04:52",
"upload_time_iso_8601": "2024-09-19T18:04:52.589730Z",
"url": "https://files.pythonhosted.org/packages/24/9a/55fff79cbc2a8ceaf5b1f8799ac14da21c39c5678a255bf11336bd3556dd/reflex_google_recaptcha_v2-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-19 18:04:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "masenf",
"github_project": "reflex-google-recaptcha-v2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "reflex-google-recaptcha-v2"
}