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

Commit 42ca658

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

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "superbalist/laravel-google-cloud-storage",
2+
"name": "superchairon/laravel-google-cloud-storage",
33
"description": "A Google Cloud Storage filesystem for Laravel",
44
"license": "MIT",
55
"authors": [

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)