Giter Club home page Giter Club logo

Comments (5)

ntward avatar ntward commented on September 14, 2024 1

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

from google-cloud-php.

bshaffer avatar bshaffer commented on September 14, 2024 1

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

I will try to fix this shortly

from google-cloud-php.

Hectorhammett avatar Hectorhammett commented on September 14, 2024

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.

from google-cloud-php.

Hectorhammett avatar Hectorhammett commented on September 14, 2024

Thanks for the update @bshaffer !

from google-cloud-php.

bshaffer avatar bshaffer commented on September 14, 2024

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

from google-cloud-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.