google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

Authentication: hashed_account_id is deprecated

Open ntward opened this issue 1 year ago • 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

ntward avatar Jul 07 '24 20:07 ntward

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.

Hectorhammett avatar Jul 12 '24 18:07 Hectorhammett

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.
}

ntward avatar Jul 18 '24 18:07 ntward

I believe this is the same issue as we've documented in https://github.com/protocolbuffers/protobuf/issues/13428

I will try to fix this shortly

bshaffer avatar Aug 08 '24 17:08 bshaffer

Thanks for the update @bshaffer !

Hectorhammett avatar Aug 09 '24 21:08 Hectorhammett

This has been fixed in the main branch of protobuf, and will be fixed in the next protobuf release (https://github.com/protocolbuffers/protobuf/commit/6d84da5e2d42a8c83373c0bc6d7ed0ca6f78aade)

bshaffer avatar Aug 20 '24 16:08 bshaffer

I am still encountering this issue:

[20-Jan-2025 13:27:14 Europe/redacted]

Log on shutdown:

hashed_account_id is deprecated.

File: redacted/vendor-composer/google/cloud-recaptcha-enterprise/src/V1/Event.php Line: 342 Request Method: POST Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15

The Error still originates from Inside the Google sdk.

manuelKruesi avatar Jan 20 '25 12:01 manuelKruesi

This should be fixed by the end of the week

bshaffer avatar May 14 '25 00:05 bshaffer

This should now be fixed! Please pull down the latest version of Recaptcha enterprise

bshaffer avatar May 20 '25 21:05 bshaffer

thank you for your effort @bshaffer! It seems like the version is not yet live on composer, see Packagist for Details. So I can not yet report the Problem as resolved.

manuelKruesi avatar May 26 '25 08:05 manuelKruesi

Same error still exists in my php 7.4, anyone have some updates?

skener avatar May 31 '25 13:05 skener

Hello,

I'm reopening this issue as I'm still seeing the hashed_account_id is deprecated notice on google/cloud-recaptcha-enterprise v2.1.2.

The original thread suggested this was resolved, but the deprecation logs are persisting in my Symfony application. The @deprecated annotation in V1/Event.php appears to be triggering E_USER_DEPRECATED notices that are caught by our logger.

Log Entry: [2025-06-24T20:45:49.936270-04:00] deprecation.INFO: User Deprecated: hashed_account_id is deprecated. {"exception":"[object] (ErrorException(code: 0): User Deprecated: hashed_account_id is deprecated. at --removed--/vendor/google/cloud-recaptcha-enterprise/src/V1/Event.php:372)"} []

Thank you.


For context, here are the relevant packages from my environment:

Relevant `composer show` output
  • google/cloud-recaptcha-enterprise 2.1.2
  • google/auth 1.47.0
  • google/gax 1.36.1
  • google/protobuf 4.31.1
  • grpc/grpc 1.57.0
  • symfony/framework-bundle 6.4.22
  • symfony/monolog-bundle 3.10.0

TipPro avatar Jun 25 '25 13:06 TipPro

Yes, unfortunately I can confirm this issues still persists on v2.1.2.

pesek avatar Jul 14 '25 11:07 pesek