Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'),
};

Expand Down
Loading