-
Resolving error while setting up Google Analytics 4 Admin service client in PHP
Hey there! Currently, I’m trying to set up the service client for GoogleAnalytics 4 Admin, but there’s a hiccup: I keep getting this pesky error. I’ve got some basic set up code here:
try { $config = [ 'keyFilename' => $this->key_file, ]; $analytics_client = new AnalyticsAdminServiceClient( $config ); } catch (Exception $ex) { print("Error creating client:" . $ex->getMessage() . " (" . $ex->getCode() . ")"); }
I’ve also gotten my hands on a key file, which looks like this:
stdClass(Array ( [installed] => stdClass Object ( [client_id] => <my client id> [project_id] => <my project id> [auth_uri] => https://accounts.google.com/o/oauth2/auth [token_uri] => https://oauth2.googleapis.com/token [auth_provider_x509_cert_url] => https://www.googleapis.com/oauth2/v1/certs [client_secret] => <my client secret> [redirect_uris] => Array ( [0] => http://localhost ) ) ) )
The error message I’m seeing is “Failed to build HttpHandler (0)”. I’m stumped- does anyone know what this error means? Is there something I should be adding to fix it?
Just a heads up, my current goal is to locate the accounts the client knows about. But, I’m hoping to eventually transfer our existing GA Universal Admin code to GA4.
Log in to reply.