Skip to content

Commit 2fda860

Browse files
authored
fix(readme): update authentication section (#11918)
* Replace authorization with authentication. * Add link to cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.
1 parent 28632c6 commit 2fda860

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

README.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,48 @@ programming language follows. This means the currently supported versions are:
2727
- Go 1.23
2828
- Go 1.24
2929

30-
## Authorization
31-
32-
By default, each API will use [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials)
33-
for authorization credentials used in calling the API endpoints. This will allow your
34-
application to run in many environments without requiring explicit configuration.
30+
## Authentication
31+
32+
By default, each client library will use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials)
33+
(ADC) to automatically configure the credentials used in calling the API endpoint.
34+
When using the libraries in a Google Cloud Platform environment such as Compute
35+
Engine, Kubernetes Engine, or App Engine, no additional authentication steps are
36+
necessary. See [Authentication methods at Google](https://cloud.google.com/docs/authentication)
37+
and [Authenticate for using client libraries](https://cloud.google.com/docs/authentication/client-libraries)
38+
for more information.
3539

3640
```go
3741
client, err := storage.NewClient(ctx)
3842
```
3943

40-
To authorize using a
41-
[JSON key file](https://cloud.google.com/iam/docs/managing-service-account-keys),
42-
pass
44+
For applications running elsewhere, such as your local development environment,
45+
you can use the `gcloud auth application-default login` command from the
46+
[Google Cloud CLI](https://cloud.google.com/cli) to set user credentials in
47+
your local filesystem. Application Default Credentials will automatically detect
48+
these credentials. See [Set up ADC for a local development
49+
environment](https://cloud.google.com/docs/authentication/set-up-adc-local-dev-environment)
50+
for more information.
51+
52+
Alternately, you may need to provide an explicit path to your credentials. To authenticate
53+
using a [service account](https://cloud.google.com/docs/authentication#service-accounts)
54+
key file, either set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path
55+
to your key file, or programmatically pass
4356
[`option.WithCredentialsFile`](https://pkg.go.dev/google.golang.org/api/option#WithCredentialsFile)
4457
to the `NewClient` function of the desired package. For example:
4558

4659
```go
4760
client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json"))
4861
```
4962

50-
You can exert more control over authorization by using the
63+
You can exert even more control over authentication by using the
5164
[credentials](https://pkg.go.dev/cloud.google.com/go/auth/credentials) package to
5265
create an [auth.Credentials](https://pkg.go.dev/cloud.google.com/go/auth#Credentials).
5366
Then pass [`option.WithAuthCredentials`](https://pkg.go.dev/google.golang.org/api/option#WithAuthCredentials)
5467
to the `NewClient` function:
5568

5669
```go
57-
creds := ...
70+
creds, err := credentials.DetectDefault(&credentials.DetectOptions{...})
71+
...
5872
client, err := storage.NewClient(ctx, option.WithAuthCredentials(creds))
5973
```
6074

0 commit comments

Comments
 (0)