@@ -75,28 +75,23 @@ The libraries that support this environment variable are:
7575### Client Authentication
7676
7777Each Google Cloud PHP client may be authenticated in code when creating a client library instance.
78-
79- Most clients use the ` credentials ` option for providing credentials as a constructor option:
78+ Most clients use the ` credentials ` option for providing explicit credentials:
8079
8180``` php
8281use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
8382
84- // Authenticating with keyfile data.
85- $video = new VideoIntelligenceServiceClient([
86- 'credentials' => json_decode(file_get_contents('/path/to/credential-file.json'), true)
87- ]);
83+ $scope = ['https://www.googleapis.com/auth/cloud-platform'];
84+ $keyFile = json_decode(file_get_contents('/path/to/service-account.json'), true);
8885
89- // Authenticating with a keyfile path.
86+ // Authenticating with keyfile data.
87+ $credentials = new ServiceAccountCredentials($scope, $keyFile);
9088$video = new VideoIntelligenceServiceClient([
91- 'credentials' => '/path/to/credential-file.json'
89+ 'credentials' => $credentials,
9290]);
9391```
9492
9593#### Note:
96- Some clients accept the ` keyFilePath ` and ` keyFile ` configuration options pointing to the credentials
97- file. However, both of these options are deprecated in favor of using the ` credentialsFetcher `
98- option or
99- [ Application Default Credentials] ( https://developers.google.com/identity/protocols/application-default-credentials ) .
94+ Some clients use the ` credentialsFetcher ` client option instead:
10095
10196``` php
10297require 'vendor/autoload.php';
@@ -105,6 +100,7 @@ use Google\Cloud\Storage\StorageClient;
105100use Google\Auth\Credentials\ServiceAccountCredentials;
106101
107102// Create the service account credentials and pass them in using the "credentialsFile" option
103+ $scope = ['https://www.googleapis.com/auth/devstorage.read_only'];
108104$keyFile = json_decode(file_get_contents('/path/to/keyfile.json'), true);
109105$storage = new StorageClient([
110106 'credentialsFetcher' => new ServiceAccountCredentials($scopes, $keyFile),
0 commit comments