Authentication: hashed_account_id is deprecated
ntward opened this issue · 5 comments
Hello,
I am using the Google\Cloud\RecaptchaEnterprise php API. I have been diligently following the docs, but keep hitting the same roadblock - I am beginning to wonder if this is an issue with the API...
I am using application default credentials with a service account key as described in the docs. I keep receiving the following error:
hashed_account_id is deprecated
As far as I can tell, there is nothing I can do as a user to resolve this - it is something internal to the library?
I see that others on StackOverflow have had the same issue:
recaptcha error hashed_account_id is deprecated
Any advice? I'm completely stuck.
Many thanks
Hello @ntward! Thanks for the comment.
Do you have a link to the specific docs you are referring to? As well as a code example to help you debug?
It does seem like the field you're trying to use is in fact deprecated. The link you shared to Stack Overflow links to the proto file:
https://github.com/googleapis/googleapis/blob/9c2348d2aa60700c15899c93e3b9615ab6ce1fcf/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto#L698C16-L698C63
It gives the recommendation to use user_info.account_id
instead.
Hello, thanks for taking the time to respond!
I was just putting together a code example. In doing so, I discovered that the minimal example worked just fine in my script, but not in my PHP app. On further investigation I realised that this is because in my app the global error handler rethrows errors as exceptions.
The suggestion to use user_info.account_id
is not possible - that logic is happening within the Google Cloud PHP code. Surely the Google Cloud PHP codebase should be updated so that this error is not raised in the first place?
Here's a minimal example (credentials and tokens omitted for obvious reasons):
declare(strict_types=1);
error_reporting(E_ALL);
require '../vendor/autoload.php';
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\Event;
use Google\Cloud\RecaptchaEnterprise\V1\Assessment;
use Google\Cloud\RecaptchaEnterprise\V1\TokenProperties\InvalidReason;
define('GOOGLE_APPLICATION_CREDENTIALS', 'PATH_HERE');
define('GOOGLE_CLOUD_PROJECT_ID', 'ID_HERE');
define('RECAPTCHA_SITE_KEY', KEY_HERE');
$token = 'TOKEN_HERE';
set_error_handler(function ($level, $message, $file = '', $line = 0) {
throw new ErrorException($message, 0, $level, $file, $line);
});
recaptchaCreateAssessment($token);
function recaptchaCreateAssessment($token) {
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . GOOGLE_APPLICATION_CREDENTIALS);
$client = new RecaptchaEnterpriseServiceClient();
$projectName = $client->projectName(GOOGLE_CLOUD_PROJECT_ID);
$event = (new Event())->setSiteKey(RECAPTCHA_SITE_KEY)->setToken($token);
$assessment = (new Assessment())->setEvent($event);
$response = $client->createAssessment($projectName,$assessment);
// This gives the 'hashed_account_id is deprecated' error.
}
I believe this is the same issue as we've documented in protocolbuffers/protobuf#13428
I will try to fix this shortly
Thanks for the update @bshaffer !
This has been fixed in the main
branch of protobuf, and will be fixed in the next protobuf release (protocolbuffers/protobuf@6d84da5)