Closed rodericktech closed 6 years ago
@rodericktech I know it's been a few years but I'm struggling to use this with a service account as well. Could you possible explain what you did to get it working?
I've created a service account already and changed the default auth_type
in the configuration file to use my service account.
In a test command I'm trying this:
$searchConsole = app(SearchConsole::class);
$sites = $searchConsole->listSites();
And getting this error
Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information
at vendor/google/auth/src/ApplicationDefaultCredentials.php:189
185▕ $creds = new GCECredentials(null, $anyScope, null, $quotaProject);
186▕ }
187▕
188▕ if (is_null($creds)) {
➜ 189▕ throw new DomainException(self::notFound());
190▕ }
191▕ if (!is_null($cache)) {
192▕ $creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
193▕ }
And I'm just lost as to what's wrong
I was able to get it to work by adding this line above my calls
putenv(sprintf('GOOGLE_APPLICATION_CREDENTIALS=%s', config('search-console.connections.service_account.application_credentials')));
Though I feel like there was probably a better way
I figured out the issue, my apologies