RecaptchaEnterprise
Hi,
I'm trying to call the Recaptcha enterprise API and I'm having some trouble knowing what's the correct format.
I see there is a Recaptcha package at vendor\google\apiclient-services\src\RecaptchaEnterprise\Resource\ProjectsKeys.php and another at vendor\google\apiclient-services\src\RecaptchaEnterprise.php
Which is the correct one to target? Would someone mind giving me a super basic example of calling the recaptcha service through this package?
Here's what I have now trying to call either of those gives me an error:
$client = new Google\Client(
[
'credentials' => './service.json',
'projectId' => 'my_project'
]
);
$service = new Google\Service\RecaptchaEnterprise($client);
//gets 401.. maybe can work somehow
print_r($service->projects_keys->listProjectsKeys('projects/000000011111'),1);
returns
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "CREDENTIALS_MISSING",
"domain": "googleapis.com",
"metadata": {
"method": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListKeys",
"service": "recaptchaenterprise.googleapis.com"
}
}
]
}
}
If I try calling the second file I get a new error:
$client = new Google\Client(
[
'credentials' => './service.json',
'projectId' => 'my_project'
]
);
$service = new Google\Service\RecaptchaEnterprise($client);
$datastore = new Google\Service\RecaptchaEnterprise\Resource\ProjectsKeys($service, $client, 'ProjectsKeys','projects/my_project');
$keylookup = $datastore->listProjectsKeys('projects/my_project');
print_r($keylookup,1);
error:
PHP Fatal error: Uncaught Error: Object of class Google\Client could not be converted to string in /root/admin-scripts/google-recaptcha/vendor/google/apiclient/src/Service/Resource.php:103```
Any help would be greatly appreciated.
Thanks
It is recommended for APIs which have a google cloud client library, to use that instead. See https://github.com/googleapis/google-cloud-php-recaptcha-enterprise
composer install google/cloud-recaptcha-enterprise