fix(storage): don't assume auth from a client option (#4982)

* fix(storage): don't assume auth from a client option

There are cases where a user might not auth with ADC or a client
option such as passing in their own client. In these cases we
should not error, but instead just not make use of the internal
cred lookup.

Fixes: #4980

* switch ordering of some lines

* add some docs
2 files changed
tree: 19adb8802c86ce089639d629f391827eecb9f025
  1. .github/
  2. .gitignore
  3. CHANGES.md
  4. CODE_OF_CONDUCT.md
  5. CONTRIBUTING.md
  6. LICENSE
  7. README.md
  8. RELEASING.md
  9. SECURITY.md
  10. accessapproval/
  11. accesscontextmanager/
  12. aiplatform/
  13. analytics/
  14. apigateway/
  15. apigeeconnect/
  16. appengine/
  17. area120/
  18. artifactregistry/
  19. asset/
  20. assuredworkloads/
  21. automl/
  22. bigquery/
  23. bigtable/
  24. billing/
  25. binaryauthorization/
  26. channel/
  27. civil/
  28. cloudbuild/
  29. clouddms/
  30. cloudtasks/
  31. cmd/
  32. compute/
  33. contactcenterinsights/
  34. container/
  35. containeranalysis/
  36. datacatalog/
  37. dataflow/
  38. datafusion/
  39. datalabeling/
  40. dataproc/
  41. dataqna/
  42. datastore/
  43. datastream/
  44. debugger/
  45. deploy/
  46. dialogflow/
  47. dlp/
  48. doc.go
  49. documentai/
  50. domains/
  51. errorreporting/
  52. essentialcontacts/
  53. eventarc/
  54. filestore/
  55. firestore/
  56. functions/
  57. gaming/
  58. gkeconnect/
  59. gkehub/
  60. go.mod
  61. go.sum
  62. grafeas/
  63. gsuiteaddons/
  64. header_test.go
  65. httpreplay/
  66. iam/
  67. iap/
  68. internal/
  69. iot/
  70. kms/
  71. language/
  72. lifesciences/
  73. logging/
  74. longrunning/
  75. managedidentities/
  76. mediatranslation/
  77. memcache/
  78. metastore/
  79. monitoring/
  80. networkconnectivity/
  81. networkmanagement/
  82. networksecurity/
  83. notebooks/
  84. orchestration/
  85. orgpolicy/
  86. osconfig/
  87. oslogin/
  88. phishingprotection/
  89. policytroubleshooter/
  90. privatecatalog/
  91. profiler/
  92. pubsub/
  93. pubsublite/
  94. recaptchaenterprise/
  95. recommendationengine/
  96. recommender/
  97. redis/
  98. resourcemanager/
  99. resourcesettings/
  100. retail/
  101. rpcreplay/
  102. scheduler/
  103. secretmanager/
  104. security/
  105. securitycenter/
  106. servicecontrol/
  107. servicedirectory/
  108. servicemanagement/
  109. serviceusage/
  110. shell/
  111. spanner/
  112. speech/
  113. storage/
  114. storagetransfer/
  115. talent/
  116. testing.md
  117. texttospeech/
  118. third_party/
  119. tpu/
  120. trace/
  121. translate/
  122. video/
  123. videointelligence/
  124. vision/
  125. vpcaccess/
  126. webrisk/
  127. websecurityscanner/
  128. workflows/
README.md

Google Cloud Client Libraries for Go

Go Reference

Go packages for Google Cloud Platform services.

import "cloud.google.com/go"

To install the packages on your system, do not clone the repo. Instead:

  1. Change to your project directory:

    cd /my/cloud/project
    
  2. Get the package you want to use. Some products have their own module, so it's best to go get the package(s) you want to use:

    $ go get cloud.google.com/go/firestore # Replace with the package you want to use.
    

NOTE: Some of these packages are under development, and may occasionally make backwards-incompatible changes.

Supported APIs

For an updated list of all of our released APIs please see our reference docs.

Go Versions Supported

We currently support Go versions 1.11 and newer.

Authorization

By default, each API will use Google Application Default Credentials for authorization credentials used in calling the API endpoints. This will allow your application to run in many environments without requiring explicit configuration.

client, err := storage.NewClient(ctx)

To authorize using a JSON key file, pass option.WithCredentialsFile to the NewClient function of the desired package. For example:

client, err := storage.NewClient(ctx, option.WithCredentialsFile("path/to/keyfile.json"))

You can exert more control over authorization by using the golang.org/x/oauth2 package to create an oauth2.TokenSource. Then pass option.WithTokenSource to the NewClient function: snip:# (auth-ts)

tokenSource := ...
client, err := storage.NewClient(ctx, option.WithTokenSource(tokenSource))

Contributing

Contributions are welcome. Please, see the CONTRIBUTING document for details.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Contributor Code of Conduct for more information.

Links