The main entry point for interacting with the reCAPTCHA API.
Public Method Summary
public abstract Task<VerificationHandle> challengeAccount (RecaptchaHandle recaptchaHandle, String challengeRequestToken)
Sends a challenge to an account in order to verify the identity of the user.
This method can be optionally called if you decide to perform a two factor authentication check on an account.
|recaptchaHandle||RecaptchaHandle initialized through
|challengeRequestToken||The challenge request token obtained through CreateAssessment().|
VerificationHandlethat can be used with
verifyAccount(String, VerificationHandle)calls. A handle is usually valid for a specific time after creation. If an expired handle is returned, meaning the operation was aborted,
getOperationAbortedToken()will return a token that can be used with the reCAPTCHA Enterprise API CreateAssessment() to get more details.
public abstract Task<Boolean> close (RecaptchaHandle handle)
Closes the initialized RecaptchaHandle.
Closes the handle if you will not be using it again to save resources.
|handle||RecaptchaHandle initialized through
- true if the handle got closed successfully for the first time, false if there wasn't anything to close (e.g., the handle was already previously closed).
public abstract Task<RecaptchaResultData> execute (RecaptchaHandle handle, RecaptchaAction action)
Returns a score indicating how likely the action was triggered by a real user. A score close to 0 indicates a likely bot, and a score close to 1 indicates a likely human.
This method should be called every time there is an action to be protected.
public abstract Task<RecaptchaHandle> init (String siteKey)
Prepares and initializes a RecaptchaHandle.
|siteKey||A site key registered for this app at //cloud.google.com/recaptcha-enterprise/docs/create-key|
public abstract Task<VerificationResult> verifyAccount (String pin, VerificationHandle verificationHandle)
Verifies a PIN against a verification handle obtained through a
challengeAccount(RecaptchaHandle, String) call.
The method should be called to verify a PIN submitted by the user. The returned
will contain a
and either a
or a new reCAPTCHA token. The four possible cases are:
- API call succeeded and the verification status is
SUCCESS: the returned
VerificationResultwill contain a new reCAPTCHA token that can be used through the reCAPTCHA Enterprise API CreateAssessment() to verify that the user was indeed verified.
- API call succeeded but the verification status is
RECAPTCHA_2FA_ABORTED: the returned
VerificationResultwill contain a new reCAPTCHA token that can be used through the reCAPTCHA Enterprise API CreateAssessment() to obtain more information on what went wrong.
- API call succeeded but the verification failed with remaining attempts:
the verification status will give more information about the failure and a new
VerificationHandlecan be obtained through the returned
VerificationResult, which you can use to call
- API call failed: an
ApiExceptionwill be thrown with a non-success
Status, which gives more information on what went wrong.
|pin||The fixed-length numerical PIN entered by the user. If a PIN with unexpected
length or non numerical characters is entered, a
|verificationHandle||A verification handle containing information required to preform the verification operation.|