Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication: hashed_account_id is deprecated #7506

Open
ntward opened this issue Jul 7, 2024 · 5 comments
Open

Authentication: hashed_account_id is deprecated #7506

ntward opened this issue Jul 7, 2024 · 5 comments
Assignees

Comments

@ntward
Copy link

ntward commented Jul 7, 2024

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

@Hectorhammett
Copy link
Collaborator

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.

@ntward
Copy link
Author

ntward commented Jul 18, 2024

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

@bshaffer
Copy link
Contributor

bshaffer commented Aug 8, 2024

I believe this is the same issue as we've documented in protocolbuffers/protobuf#13428

I will try to fix this shortly

@bshaffer bshaffer self-assigned this Aug 8, 2024
@Hectorhammett
Copy link
Collaborator

Thanks for the update @bshaffer !

@bshaffer
Copy link
Contributor

This has been fixed in the main branch of protobuf, and will be fixed in the next protobuf release (protocolbuffers/protobuf@6d84da5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants