Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 62a563a

Browse files
Jorge RodriguezJorge Rodriguez
authored andcommitted
bugfix: allow authentication with automatic GCP discovery
1 parent 249a7de commit 62a563a

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/GoogleCloudStorageServiceProvider.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,24 @@ public function boot()
8484
*/
8585
private function createClient($config)
8686
{
87-
$keyFile = array_get($config, 'key_file');
88-
if (is_string($keyFile)) {
89-
return new StorageClient([
90-
'projectId' => $config['project_id'],
91-
'keyFilePath' => $keyFile,
92-
]);
87+
$options = [];
88+
if (isset($config['project_id'])) {
89+
$options['projectId'] = $config['project_id'];
9390
}
9491

95-
if (! is_array($keyFile)) {
96-
$keyFile = [];
92+
if (isset($config['key_file'])) {
93+
$keyFile = array_get($config, 'key_file');
94+
if (is_string($keyFile)) {
95+
$options['keyFilePath'] = $keyFile;
96+
} else {
97+
if (! is_array($keyFile)) {
98+
$keyFile = [];
99+
}
100+
$options['keyFile'] = array_merge(["project_id" => $config['project_id']], $keyFile);
101+
}
97102
}
98-
return new StorageClient([
99-
'projectId' => $config['project_id'],
100-
'keyFile' => array_merge(["project_id" => $config['project_id']], $keyFile)
101-
]);
103+
104+
return new StorageClient($options);
102105
}
103106

104107
/**

0 commit comments

Comments
 (0)