use of com.google.recaptchaenterprise.v1.GetKeyRequest in project java-recaptchaenterprise by googleapis.
the class GetSiteKey method getSiteKey.
/**
* Get the reCAPTCHA site key present under the project ID.
*
* @param projectID: GCloud Project ID.
* @param recaptchaSiteKey: Specify the site key to get the details.
*/
public static void getSiteKey(String projectID, String recaptchaSiteKey) throws IOException, InterruptedException, ExecutionException, TimeoutException {
// clean up any remaining background resources.
try (RecaptchaEnterpriseServiceClient client = RecaptchaEnterpriseServiceClient.create()) {
// Construct the "GetSiteKey" request.
GetKeyRequest getKeyRequest = GetKeyRequest.newBuilder().setName(KeyName.of(projectID, recaptchaSiteKey).toString()).build();
// Wait for the operation to complete.
ApiFuture<Key> futureCall = client.getKeyCallable().futureCall(getKeyRequest);
Key key = futureCall.get(5, TimeUnit.SECONDS);
System.out.println("Successfully obtained the key !" + key.getName());
}
}
Aggregations