From ff3968532c6624c1579ae8d0bc65bb87c5f551bb Mon Sep 17 00:00:00 2001 From: Mahmoud Ashraf <182176867+SNO7E-G@users.noreply.github.com> Date: Fri, 24 Jul 2026 00:02:55 +0500 Subject: [PATCH] docs: fix ADC specific-JSON-key example in README The "Call using a specific JSON key" snippet did not parse: - trailing comma after the first ServiceAccountCredentials assignment - $scope used in the match arms where the defined variable is $scopes - missing imports for ServiceAccountCredentials, UserRefreshCredentials and FetchAuthTokenCache --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a8d77d692..a54d7210b 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,9 @@ If you want to use a specific JSON key instead of using `GOOGLE_APPLICATION_CRED do this: ```php -use Google\Auth\CredentialsLoader; +use Google\Auth\Credentials\ServiceAccountCredentials; +use Google\Auth\Credentials\UserRefreshCredentials; +use Google\Auth\FetchAuthTokenCache; use Google\Auth\Middleware\AuthTokenMiddleware; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; @@ -172,13 +174,13 @@ $jsonKey = ['key' => 'value']; $scopes = ['https://www.googleapis.com/auth/drive.readonly']; // Load credentials from JSON containing service account credentials. -$creds = new ServiceAccountCredentials($scopes, $jsonKey), +$creds = new ServiceAccountCredentials($scopes, $jsonKey); // For other credentials types, create those classes explicitly using the // "type" field in the JSON key, for example: $creds = match ($jsonKey['type']) { - 'service_account' => new ServiceAccountCredentials($scope, $jsonKey), - 'authorized_user' => new UserRefreshCredentials($scope, $jsonKey), + 'service_account' => new ServiceAccountCredentials($scopes, $jsonKey), + 'authorized_user' => new UserRefreshCredentials($scopes, $jsonKey), default => throw new InvalidArgumentException('This application only supports service account and user account credentials'), };