-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle captcha in North America (#665)
* Allow for captcha in North America * Fix for sphinx-rtd-theme>=3.0 * Add MyBMWCaptchaMissingError * Add sitekey to const * Add --captcha-token to CLI * Update CLI documentation
- Loading branch information
Showing
12 changed files
with
164 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Form with hCaptcha</title> | ||
</head> | ||
<body> | ||
<p></p> | ||
<div id="captchaResponse"> | ||
<div style="text-align: center;"> | ||
<form id="captcha_form" action="#" method="post"> | ||
<!-- hCaptcha widget --> | ||
<div class="h-captcha" data-sitekey="dc24de9a-9844-438b-b542-60067ff4dbe9"></div><br> | ||
<button type="submit" class="btn">Submit</button> | ||
</form> | ||
|
||
<!-- hCaptcha script --> | ||
<script src="https://hcaptcha.com/1/api.js" async defer></script> | ||
</div> | ||
</div> | ||
<p></p> | ||
<script> | ||
document.getElementById('captcha_form').addEventListener('submit', function(event) { | ||
event.preventDefault(); // Prevent the default form submission | ||
|
||
const hCaptchaResponse = document.querySelector('[name="h-captcha-response"]').value; | ||
const responseElement = document.getElementById('captchaResponse'); | ||
|
||
if (hCaptchaResponse) { | ||
content = '<div class="highlight"><pre style="word-break: break-all; white-space: pre-wrap;">' | ||
content += hCaptchaResponse | ||
content += '</pre></div>'; | ||
responseElement.innerHTML = content; | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Captcha (North America) | ||
======================= | ||
|
||
Login to the :code:`north_america` region requires a captcha to be solved. Submit below form and use the returned token when creating the account object. | ||
|
||
:: | ||
|
||
account = MyBMWAccount(USERNAME, PASSWORD, Regions.REST_OF_WORLD, hcaptcha_token=HCAPTCHA_TOKEN) | ||
|
||
When using the CLI, pass the token via the :code:`--hcaptcha-token` argument (see `CLI documentation <cli.html#named-arguments>`_). | ||
|
||
.. note:: | ||
Only the first login requires a captcha to be solved. Follow-up logins using refresh token do not require a captcha. | ||
This requires the tokens to be stored in a file (default behavior when using the CLI) or in the python object itself. | ||
|
||
.. raw:: html | ||
:file: _static/captcha_north_america.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
:maxdepth: 2 | ||
:glob: | ||
|
||
captcha | ||
development/* | ||
|
||
|
||
|