Comments (3)
Thanks for more info.
What's happening here is that error is being thrown from auth library as part of the GRPC Transport when it's trying to fetch the auth token. Doing so, it will always use HTTP (hence REST).
Exceptions are wrapped as ApiCore\ApiException
so that they don't differ with transport (GRPC or REST). But since auth calls are always HTTP and they don't change based on transport so they are not wrapped.
It's not intuitive but it's still Working as Intended.
from gax-php.
Hi @tscni, thanks for raising this.
Can you please provide a repro case for this error so that I can try this out at my end?
Also, can you try doing this with latest versions of gax-php
and auth
and see if the error exists?
from gax-php.
Sure (I'm using google/cloud-retail
as an example here)
- Use PHP 8.1 (the version shouldn't matter) + necessary common extensions (like curl)
- Create the following files in a new direfctory
- composer.json
{ "require": { "google/auth": "1.28.0", "google/cloud-retail": "1.4.0", "google/gax": "1.21.1" } }
- index.php
<?php use Google\Cloud\Retail\V2\PredictionServiceClient; use Google\Cloud\Retail\V2\UserEvent; require __DIR__ . '/vendor/autoload.php'; $client = new PredictionServiceClient([ 'credentials' => [ 'type' => 'authorized_user', 'client_id' => 'invalid', 'client_secret' => 'invalid', 'refresh_token' => 'invalid', ], ]); try { $client->predict('placement', new UserEvent()); } catch (Throwable $exception) { var_dump($exception->getMessage()); var_dump(get_class($exception)); }
- composer.json
- Run
composer install
in that directory - Run
php index.php
- Observe expected (-) vs. actual (+) output
string(190) "Client error: `POST https://oauth2.googleapis.com/token` resulted in a `401 Unauthorized` response: { "error": "invalid_client", "error_description": "The OAuth client was not found." } " -string(27) "Google\ApiCore\ApiException" +string(36) "GuzzleHttp\Exception\ClientException"
- Remove your internet connection
- Run
php index.php
- Observe expected (-) vs. actual (+) output
string(156) "cURL error 6: Could not resolve host: oauth2.googleapis.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://oauth2.googleapis.com/token" -string(27) "Google\ApiCore\ApiException" +string(37) "GuzzleHttp\Exception\ConnectException"
from gax-php.
Related Issues (20)
- [Policy Bot] found one or more issues with this repository.
- Follow the standard PSR-15 HOT 1
- Updating to v1.11 throws Fatal Error in ServerStreamingCallWrapper HOT 1
- Upgrading to v1.11.2 breaks the unit test of our (lonely) streaming method HOT 7
- Different string case used for metadata field names using REST and gRPC transports HOT 5
- Unimplemented REST method returns configuration error since 1.11.0 HOT 3
- CredentialsWrapper doesn't use authCache when building ApplicationDefaultCredentials HOT 1
- syntax error, unexpected token "readonly", expecting identifier HOT 4
- PHP 8.1 Deprecation HOT 3
- Call to undefined method Google\Auth\CredentialsLoader::shouldLoadClientCertSource() HOT 2
- feat: add strict types to all class files
- Warning on PHP 8.1 in Polling Trait HOT 1
- ApiException::create() throws a fatal error when the error['message'] is not set. HOT 1
- how can i config auth http handler for CredentialsWrapper and how to make it become effective. HOT 4
- Feature Request: add GAPIC surface version to the x-goog header HOT 1
- pollUntilComplete unauthenticated while (successfully) creating glossary HOT 1
- Creation of dynamic property Google\ApiCore\Tests\Unit\GapicClientTraitStub::$newClient is deprecated HOT 1
- Documentation generation is broken
- Bug Regarding URI Template HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gax-php.