Skip to content

Commit 04fd65a

Browse files
authored
docs: document keyFilePath and keyFile usage in AUTHENTICATION.md (#8575)
1 parent 89de3fc commit 04fd65a

4 files changed

Lines changed: 62 additions & 120 deletions

File tree

AUTHENTICATION.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ Each Google Cloud PHP client may be authenticated in code when creating a client
7979
Most clients use the `credentials` option for providing credentials as a constructor option:
8080

8181
```php
82-
require 'vendor/autoload.php';
83-
8482
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
8583

8684
// Authenticating with keyfile data.
@@ -94,6 +92,36 @@ $video = new VideoIntelligenceServiceClient([
9492
]);
9593
```
9694

95+
#### Note:
96+
Some clients accept the `keyFilePath` and `keyFile` configuration options pointing to the credentials file:
97+
98+
```php
99+
use Google\Cloud\Storage\StorageClient;
100+
101+
// Authenticate using a keyfile path
102+
$cloud = new StorageClient([
103+
'keyFilePath' => 'path/to/keyfile.json'
104+
]);
105+
106+
// Authenticate using keyfile data
107+
$cloud = new StorageClient([
108+
'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
109+
]);
110+
```
111+
A list of clients that accept these parameters are:
112+
- [Bigtable](https://github.com/googleapis/google-cloud-php-bigtable)
113+
- [Spanner](https://github.com/googleapis/google-cloud-php-spanner)
114+
- [Firestore](https://github.com/googleapis/google-cloud-php-firestore)
115+
- [Datastore](https://github.com/googleapis/google-cloud-php-datastore)
116+
- [Pubsub](https://github.com/googleapis/google-cloud-php-pubsub)
117+
- [Logging](https://github.com/googleapis/google-cloud-php-logging)
118+
- [Translate](https://github.com/googleapis/google-cloud-php-translate)
119+
- [Bigquery](https://github.com/googleapis/google-cloud-php-bigquery)
120+
- [Storage](https://github.com/googleapis/google-cloud-php-storage)
121+
122+
We recommend to visit the Check the [client documentation][php-ref-docs] for the client library you're using
123+
for more in depth information.
124+
97125
### Local ADC file
98126

99127
This option allows for an easy way to authenticate in a local environment during development. If

README.md

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,64 +98,7 @@ var_dump($response->getTranslations()[0]);
9898

9999
### Authentication
100100

101-
#### Note
102-
This quickstart is built with local development in mind. The steps for deploying your project are
103-
different depending on the environment you use. Here we provide some basic instruction in how to get
104-
started with deployment of your project:
105-
106-
* For applications running elsewhere, authentication is usually accomplished using a Service
107-
Account.
108-
109-
For more information on obtaining Service Account credentials see our
110-
[Authentication Guide](https://cloud.google.com/docs/authentication/production#manually). Set the
111-
`GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to your credentials file.
112-
113-
#### Note:
114-
Some clients accept the `keyFilePath` and `keyFile` configuration options pointing to the credentials file:
115-
116-
```php
117-
require 'vendor/autoload.php';
118-
119-
use Google\Cloud\Storage\StorageClient;
120-
121-
// Authenticate using a keyfile path
122-
$cloud = new StorageClient([
123-
'keyFilePath' => 'path/to/keyfile.json'
124-
]);
125-
126-
// Authenticate using keyfile data
127-
$cloud = new StorageClient([
128-
'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
129-
]);
130-
```
131-
A list of clients that accept these parameters are:
132-
- [Bigtable](https://github.com/googleapis/google-cloud-php-bigtable)
133-
- [Spanner](https://github.com/googleapis/google-cloud-php-spanner)
134-
- [Firestore](https://github.com/googleapis/google-cloud-php-firestore)
135-
- [Datastore](https://github.com/googleapis/google-cloud-php-datastore)
136-
- [Pubsub](https://github.com/googleapis/google-cloud-php-pubsub)
137-
- [Logging](https://github.com/googleapis/google-cloud-php-logging)
138-
- [Translate](https://github.com/googleapis/google-cloud-php-translate)
139-
- [Bigquery](https://github.com/googleapis/google-cloud-php-bigquery)
140-
- [Storage](https://github.com/googleapis/google-cloud-php-storage)
141-
142-
We recommend to visit the Check the [client documentation][php-ref-docs] for the client library you're using for more in depth information.
143-
144-
[php-ref-docs]: https://cloud.google.com/php/docs/reference
145-
146-
If you do not wish to embed your authentication information in your application code, you may also make use of [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
147-
148-
```php
149-
require 'vendor/autoload.php';
150-
151-
use Google\Cloud\Storage\StorageClient;
152-
153-
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json');
154-
155-
$cloud = new StorageClient();
156-
```
157-
158-
The `GOOGLE_APPLICATION_CREDENTIALS` environment variable may be set in your server configuration.
101+
See [AUTHENTICATION.md](AUTHENTICATION.md)
159102

160103
### Debugging
161104

dev/tests/fixtures/docfx/ProductNeutralGuides/authentication.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ Each Google Cloud PHP client may be authenticated in code when creating a client
7979
Most clients use the `credentials` option for providing credentials as a constructor option:
8080

8181
```php
82-
require 'vendor/autoload.php';
83-
8482
use Google\Cloud\VideoIntelligence\V1\VideoIntelligenceServiceClient;
8583

8684
// Authenticating with keyfile data.
@@ -94,6 +92,36 @@ $video = new VideoIntelligenceServiceClient([
9492
]);
9593
```
9694

95+
#### Note:
96+
Some clients accept the `keyFilePath` and `keyFile` configuration options pointing to the credentials file:
97+
98+
```php
99+
use Google\Cloud\Storage\StorageClient;
100+
101+
// Authenticate using a keyfile path
102+
$cloud = new StorageClient([
103+
'keyFilePath' => 'path/to/keyfile.json'
104+
]);
105+
106+
// Authenticate using keyfile data
107+
$cloud = new StorageClient([
108+
'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
109+
]);
110+
```
111+
A list of clients that accept these parameters are:
112+
- [Bigtable](https://github.com/googleapis/google-cloud-php-bigtable)
113+
- [Spanner](https://github.com/googleapis/google-cloud-php-spanner)
114+
- [Firestore](https://github.com/googleapis/google-cloud-php-firestore)
115+
- [Datastore](https://github.com/googleapis/google-cloud-php-datastore)
116+
- [Pubsub](https://github.com/googleapis/google-cloud-php-pubsub)
117+
- [Logging](https://github.com/googleapis/google-cloud-php-logging)
118+
- [Translate](https://github.com/googleapis/google-cloud-php-translate)
119+
- [Bigquery](https://github.com/googleapis/google-cloud-php-bigquery)
120+
- [Storage](https://github.com/googleapis/google-cloud-php-storage)
121+
122+
We recommend to visit the Check the [client documentation][php-ref-docs] for the client library you're using
123+
for more in depth information.
124+
97125
### Local ADC file
98126

99127
This option allows for an easy way to authenticate in a local environment during development. If

dev/tests/fixtures/docfx/ProductNeutralGuides/getting-started.md

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -98,64 +98,7 @@ var_dump($response->getTranslations()[0]);
9898

9999
### Authentication
100100

101-
#### Note
102-
This quickstart is built with local development in mind. The steps for deploying your project are
103-
different depending on the environment you use. Here we provide some basic instruction in how to get
104-
started with deployment of your project:
105-
106-
* For applications running elsewhere, authentication is usually accomplished using a Service
107-
Account.
108-
109-
For more information on obtaining Service Account credentials see our
110-
[Authentication Guide](https://cloud.google.com/docs/authentication/production#manually). Set the
111-
`GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to your credentials file.
112-
113-
#### Note:
114-
Some clients accept the `keyFilePath` and `keyFile` configuration options pointing to the credentials file:
115-
116-
```php
117-
require 'vendor/autoload.php';
118-
119-
use Google\Cloud\Storage\StorageClient;
120-
121-
// Authenticate using a keyfile path
122-
$cloud = new StorageClient([
123-
'keyFilePath' => 'path/to/keyfile.json'
124-
]);
125-
126-
// Authenticate using keyfile data
127-
$cloud = new StorageClient([
128-
'keyFile' => json_decode(file_get_contents('/path/to/keyfile.json'), true)
129-
]);
130-
```
131-
A list of clients that accept these parameters are:
132-
- [Bigtable](https://github.com/googleapis/google-cloud-php-bigtable)
133-
- [Spanner](https://github.com/googleapis/google-cloud-php-spanner)
134-
- [Firestore](https://github.com/googleapis/google-cloud-php-firestore)
135-
- [Datastore](https://github.com/googleapis/google-cloud-php-datastore)
136-
- [Pubsub](https://github.com/googleapis/google-cloud-php-pubsub)
137-
- [Logging](https://github.com/googleapis/google-cloud-php-logging)
138-
- [Translate](https://github.com/googleapis/google-cloud-php-translate)
139-
- [Bigquery](https://github.com/googleapis/google-cloud-php-bigquery)
140-
- [Storage](https://github.com/googleapis/google-cloud-php-storage)
141-
142-
We recommend to visit the Check the [client documentation][php-ref-docs] for the client library you're using for more in depth information.
143-
144-
[php-ref-docs]: https://cloud.google.com/php/docs/reference
145-
146-
If you do not wish to embed your authentication information in your application code, you may also make use of [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
147-
148-
```php
149-
require 'vendor/autoload.php';
150-
151-
use Google\Cloud\Storage\StorageClient;
152-
153-
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json');
154-
155-
$cloud = new StorageClient();
156-
```
157-
158-
The `GOOGLE_APPLICATION_CREDENTIALS` environment variable may be set in your server configuration.
101+
See [AUTHENTICATION.md](AUTHENTICATION.md)
159102

160103
### Debugging
161104

0 commit comments

Comments
 (0)