Twisted-based reCAPTCHA client.
This client always uses TLS with strict hostname checking, unlike the official Google Python recaptcha-client, which is hardcoded to use plaintext HTTP.
Small portions of this code were taken from the official Google Python
recaptcha-client module, version 1.0.6. Those portions are
RecaptchaResponse
, API_SERVER
, They total 5 lines of code,
which are copyright the authors of the recaptcha-client package.
API_SSL_SERVER
= 'https://www.google.com/recaptcha/api'¶This was taken from recaptcha.client.captcha.API_SSL_SERVER
.
API_SERVER
= 'https://www.google.com/recaptcha/api'¶This was taken from recaptcha.client.captcha.API_SSL_SERVER
.
GOOGLE_INTERNET_AUTHORITY_CA_CERT
= <OpenSSL.crypto.X509 object>¶(OpenSSL.crypto.X509
) Only trust certificate for the reCAPTCHA
API_SSL_SERVER
which were signed by the Google Internet Authority CA.
RecaptchaResponseError
[source]¶Bases: exceptions.ValueError
There was an error with the reCaptcha API server’s response.
RecaptchaResponse
(is_valid, error_code=None)[source]¶Bases: object
Taken from recaptcha.client.captcha.RecaptchaResponse.
RecaptchaResponseProtocol
(finished)[source]¶Bases: twisted.internet.protocol.Protocol
HTML parser which creates a RecaptchaResponse
from the body of
the reCaptcha API server’s response.
Create a protocol for creating
RecaptchaResponses
.
Parameters: | finished (twisted.internet.defer.Deferred) – A deferred which will have its callback() called
with a RecaptchaResponse . |
---|
connectionLost
(reason)[source]¶Called when the connection was closed.
Parameters: | reason (twisted.python.failure.Failure) – A string explaning why the connection was closed,
wrapped in a Failure instance. |
---|
submit
(recaptcha_challenge_field, recaptcha_response_field, private_key, remoteip, agent=<twisted.web.client.Agent object>)[source]¶Submits a reCaptcha request for verification. This function is a patched
version of the recaptcha.client.captcha.submit()
function in
reCaptcha’s Python API.
This function returns a twisted.internet.defer.Deferred. If you
need a recaptcha.client.captcha.RecaptchaResponse
to be returned, use
the submit()
function, which is an @inlineCallbacks
wrapper for
this function.
Parameters: |
|
---|---|
Return type: | |
Returns: | A |