tree: 032f1a4f843f95344a0e299040b3d59507713a64 [path history] [tgz]
  1. abusiveexperiencereport/
  2. acceleratedmobilepageurl/
  3. accesscontextmanager/
  4. adexchangebuyer/
  5. adexchangebuyer2/
  6. adexchangeseller/
  7. adexperiencereport/
  8. admin/
  9. adsense/
  10. adsensehost/
  11. alertcenter/
  12. analytics/
  13. analyticsreporting/
  14. androiddeviceprovisioning/
  15. androidenterprise/
  16. androidmanagement/
  17. androidpublisher/
  18. appengine/
  19. appsactivity/
  20. appstate/
  21. bigquery/
  22. bigquerydatatransfer/
  23. bigtableadmin/
  24. binaryauthorization/
  25. blogger/
  26. books/
  27. calendar/
  28. chat/
  29. civicinfo/
  30. classroom/
  31. cloudasset/
  32. cloudbilling/
  33. cloudbuild/
  34. clouddebugger/
  35. clouderrorreporting/
  36. cloudfunctions/
  37. cloudidentity/
  38. cloudiot/
  39. cloudkms/
  40. cloudprofiler/
  41. cloudresourcemanager/
  42. cloudscheduler/
  43. cloudsearch/
  44. cloudshell/
  45. cloudtasks/
  46. cloudtrace/
  47. composer/
  48. compute/
  49. consumersurveys/
  50. container/
  51. containeranalysis/
  52. content/
  53. customsearch/
  54. dataflow/
  55. dataproc/
  56. datastore/
  57. deploymentmanager/
  58. dfareporting/
  59. dialogflow/
  60. digitalassetlinks/
  61. discovery/
  62. dlp/
  63. dns/
  64. doubleclickbidmanager/
  65. doubleclicksearch/
  66. drive/
  67. driveactivity/
  68. examples/
  69. file/
  70. firebasedynamiclinks/
  71. firebasehosting/
  72. firebaseremoteconfig/
  73. firebaserules/
  74. firestore/
  75. fitness/
  76. fusiontables/
  77. games/
  78. gamesconfiguration/
  79. gamesmanagement/
  80. genomics/
  81. gensupport/
  82. gmail/
  83. google-api-go-generator/
  84. googleapi/
  85. groupsmigration/
  86. groupssettings/
  87. iam/
  88. iamcredentials/
  89. iap/
  90. identitytoolkit/
  91. indexing/
  92. integration-tests/
  93. internal/
  94. iterator/
  95. jobs/
  96. kgsearch/
  97. language/
  98. lib/
  99. libraryagent/
  100. licensing/
  101. logging/
  102. manufacturers/
  103. mirror/
  104. ml/
  105. monitoring/
  106. oauth2/
  107. option/
  108. oslogin/
  109. pagespeedonline/
  110. partners/
  111. people/
  112. photoslibrary/
  113. playcustomapp/
  114. playmoviespartner/
  115. plus/
  116. plusdomains/
  117. poly/
  118. prediction/
  119. proximitybeacon/
  120. pubsub/
  121. qpxexpress/
  122. redis/
  123. remotebuildexecution/
  124. replicapool/
  125. replicapoolupdater/
  126. reseller/
  127. runtimeconfig/
  128. safebrowsing/
  129. script/
  130. searchconsole/
  131. servicebroker/
  132. serviceconsumermanagement/
  133. servicecontrol/
  134. servicemanagement/
  135. servicenetworking/
  136. serviceusage/
  137. serviceuser/
  138. sheets/
  139. siteverification/
  140. slides/
  141. sourcerepo/
  142. spanner/
  143. spectrum/
  144. speech/
  145. sqladmin/
  146. storage/
  147. storagetransfer/
  148. streetviewpublish/
  149. support/
  150. surveys/
  151. tagmanager/
  152. tasks/
  153. testing/
  154. texttospeech/
  155. toolresults/
  156. tpu/
  157. tracing/
  158. translate/
  159. transport/
  160. urlshortener/
  161. vault/
  162. videointelligence/
  163. vision/
  164. webfonts/
  165. webmasters/
  166. websecurityscanner/
  167. youtube/
  168. youtubeanalytics/
  169. youtubereporting/
  170. .gitignore
  171. .hgtags
  172. api-list.json
  173. AUTHORS
  174. CONTRIBUTING.md
  175. CONTRIBUTORS
  176. GettingStarted.md
  177. go.mod
  178. go.sum
  179. key.json.enc
  180. LICENSE
  181. NOTES
  182. README.md
  183. TODO
  184. tools.go
README.md

Google APIs Client Library for Go

Getting Started

$ go get google.golang.org/api/tasks/v1
$ go get google.golang.org/api/moderator/v1
$ go get google.golang.org/api/urlshortener/v1
... etc ...

and using:

package main

import (
	"net/http"

	"google.golang.org/api/urlshortener/v1"
)

func main() {
	svc, err := urlshortener.New(http.DefaultClient)
	// ...
}

Status

GoDoc

These are auto-generated Go libraries from the Google Discovery Service's JSON description files of the available “new style” Google APIs.

Due to the auto-generated nature of this collection of libraries, complete APIs or specific versions can appear or go away without notice. As a result, you should always locally vendor any API(s) that your code relies upon.

These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, consider using the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.

The generator itself and the code it produces are beta. Some APIs are alpha/beta, and indicated as such in the import path (e.g., “google.golang.org/api/someapi/v1alpha”).

Application Default Credentials Example

Application Default Credentials provide a simplified way to obtain credentials for authenticating with Google APIs.

The Application Default Credentials authenticate as the application itself, which make them great for working with Google Cloud APIs like Storage or Datastore. They are the recommended form of authentication when building applications that run on Google Compute Engine or Google App Engine.

Default credentials are provided by the golang.org/x/oauth2/google package. To use them, add the following import:

import "golang.org/x/oauth2/google"

Some credentials types require you to specify scopes, and service entry points may not inject them. If you encounter this situation you may need to specify scopes as follows:

import (
        "context"
        "golang.org/x/oauth2/google"
        "google.golang.org/api/compute/v1"
)

func main() {
        // Use oauth2.NoContext if there isn't a good context to pass in.
        ctx := context.Background()

        client, err := google.DefaultClient(ctx, compute.ComputeScope)
        if err != nil {
                //...
        }
        computeService, err := compute.New(client)
        if err != nil {
                //...
        }
}

If you need a oauth2.TokenSource, use the DefaultTokenSource function:

ts, err := google.DefaultTokenSource(ctx, scope1, scope2, ...)
if err != nil {
        //...
}
client := oauth2.NewClient(ctx, ts)

See also: golang.org/x/oauth2/google package documentation.