fix(auth): default gRPC token type to Bearer if not set (#9800)

As documented on auth.Token.Type, if the value of Type is "" it should be treated as a Bearer token. Added a similar helper method as we have in the httptransport package to default this.
3 files changed
tree: 67b04b82bac743e7fc99b257ef6bea41345dd9a7
  1. .devcontainer/
  2. .github/
  3. accessapproval/
  4. accesscontextmanager/
  5. advisorynotifications/
  6. ai/
  7. aiplatform/
  8. alloydb/
  9. analytics/
  10. apigateway/
  11. apigeeconnect/
  12. apigeeregistry/
  13. apikeys/
  14. appengine/
  15. apphub/
  16. apps/
  17. area120/
  18. artifactregistry/
  19. asset/
  20. assuredworkloads/
  21. auth/
  22. automl/
  23. backupdr/
  24. baremetalsolution/
  25. batch/
  26. beyondcorp/
  27. bigquery/
  28. bigtable/
  29. billing/
  30. binaryauthorization/
  31. certificatemanager/
  32. channel/
  33. civil/
  34. cloudbuild/
  35. cloudcontrolspartner/
  36. clouddms/
  37. cloudprofiler/
  38. cloudquotas/
  39. cloudtasks/
  40. commerce/
  41. compute/
  42. confidentialcomputing/
  43. config/
  44. contactcenterinsights/
  45. container/
  46. containeranalysis/
  47. datacatalog/
  48. dataflow/
  49. dataform/
  50. datafusion/
  51. datalabeling/
  52. dataplex/
  53. dataproc/
  54. dataqna/
  55. datastore/
  56. datastream/
  57. debugger/
  58. deploy/
  59. dialogflow/
  60. discoveryengine/
  61. dlp/
  62. documentai/
  63. domains/
  64. edgecontainer/
  65. edgenetwork/
  66. errorreporting/
  67. essentialcontacts/
  68. eventarc/
  69. filestore/
  70. firestore/
  71. functions/
  72. gkebackup/
  73. gkeconnect/
  74. gkehub/
  75. gkemulticloud/
  76. grafeas/
  77. gsuiteaddons/
  78. httpreplay/
  79. iam/
  80. iap/
  81. ids/
  82. internal/
  83. iot/
  84. kms/
  85. language/
  86. lifesciences/
  87. logging/
  88. longrunning/
  89. managedidentities/
  90. maps/
  91. mediatranslation/
  92. memcache/
  93. metastore/
  94. migrationcenter/
  95. monitoring/
  96. netapp/
  97. networkconnectivity/
  98. networkmanagement/
  99. networksecurity/
  100. notebooks/
  101. optimization/
  102. orchestration/
  103. orgpolicy/
  104. osconfig/
  105. oslogin/
  106. parallelstore/
  107. phishingprotection/
  108. policysimulator/
  109. policytroubleshooter/
  110. privatecatalog/
  111. profiler/
  112. pubsub/
  113. pubsublite/
  114. rapidmigrationassessment/
  115. recaptchaenterprise/
  116. recommendationengine/
  117. recommender/
  118. redis/
  119. resourcemanager/
  120. resourcesettings/
  121. retail/
  122. rpcreplay/
  123. run/
  124. scheduler/
  125. secretmanager/
  126. securesourcemanager/
  127. security/
  128. securitycenter/
  129. securitycentermanagement/
  130. securityposture/
  131. servicecontrol/
  132. servicedirectory/
  133. servicehealth/
  134. servicemanagement/
  135. serviceusage/
  136. shell/
  137. shopping/
  138. spanner/
  139. speech/
  140. storage/
  141. storageinsights/
  142. storagetransfer/
  143. support/
  144. talent/
  145. telcoautomation/
  146. texttospeech/
  147. third_party/
  148. tpu/
  149. trace/
  150. translate/
  151. vertexai/
  152. video/
  153. videointelligence/
  154. vision/
  155. visionai/
  156. vmmigration/
  157. vmwareengine/
  158. vpcaccess/
  159. webrisk/
  160. websecurityscanner/
  161. workflows/
  162. workstations/
  163. .gitignore
  164. .release-please-manifest-individual.json
  165. .release-please-manifest-submodules.json
  166. .release-please-manifest.json
  167. CHANGES.md
  168. CODE_OF_CONDUCT.md
  169. CONTRIBUTING.md
  170. debug.md
  171. doc.go
  172. go.mod
  173. go.sum
  174. go.work
  175. go.work.sum
  176. LICENSE
  177. migration.md
  178. README.md
  179. release-please-config-individual.json
  180. release-please-config-yoshi-submodules.json
  181. release-please-config.json
  182. RELEASING.md
  183. SECURITY.md
  184. testing.md
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

Our libraries are compatible with at least the three most recent, major Go releases. They are currently compatible with:

  • Go 1.22
  • Go 1.21
  • Go 1.20
  • Go 1.19

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:

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