google-api-go-client: add request hooks.

This will be used to attach a hook for adding Cloud Trace spans to API calls.

Change-Id: I0c4536d491ac2add167a6e1af6969585a1d646b8
Reviewed-on: https://code-review.googlesource.com/5255
Reviewed-by: Michael McGreevy <mcgreevy@golang.org>
164 files changed
tree: 0f8f4229dfa02ea1e2ad6397cfbfff7f7e8a8239
  1. acceleratedmobilepageurl/
  2. adexchangebuyer/
  3. adexchangebuyer2/
  4. adexchangeseller/
  5. admin/
  6. adsense/
  7. adsensehost/
  8. analytics/
  9. analyticsreporting/
  10. androidenterprise/
  11. androidpublisher/
  12. appengine/
  13. appsactivity/
  14. appstate/
  15. autoscaler/
  16. bigquery/
  17. blogger/
  18. books/
  19. calendar/
  20. civicinfo/
  21. classroom/
  22. cloudbilling/
  23. cloudbuild/
  24. clouddebugger/
  25. clouderrorreporting/
  26. cloudlatencytest/
  27. cloudmonitoring/
  28. cloudresourcemanager/
  29. cloudtrace/
  30. clouduseraccounts/
  31. compute/
  32. consumersurveys/
  33. container/
  34. content/
  35. coordinate/
  36. customsearch/
  37. dataflow/
  38. dataproc/
  39. datastore/
  40. deploymentmanager/
  41. dfareporting/
  42. discovery/
  43. dns/
  44. doubleclickbidmanager/
  45. doubleclicksearch/
  46. drive/
  47. examples/
  48. firebaserules/
  49. fitness/
  50. freebase/
  51. fusiontables/
  52. games/
  53. gamesconfiguration/
  54. gamesmanagement/
  55. gan/
  56. genomics/
  57. gensupport/
  58. gmail/
  59. google-api-go-generator/
  60. googleapi/
  61. groupsmigration/
  62. groupssettings/
  63. iam/
  64. identitytoolkit/
  65. integration-tests/
  66. internal/
  67. kgsearch/
  68. lib/
  69. licensing/
  70. logging/
  71. manager/
  72. mapsengine/
  73. mirror/
  74. monitoring/
  75. oauth2/
  76. option/
  77. pagespeedonline/
  78. partners/
  79. people/
  80. playmoviespartner/
  81. plus/
  82. plusdomains/
  83. prediction/
  84. proximitybeacon/
  85. pubsub/
  86. qpxexpress/
  87. replicapool/
  88. replicapoolupdater/
  89. reseller/
  90. resourceviews/
  91. runtimeconfig/
  92. safebrowsing/
  93. script/
  94. serviceregistry/
  95. sheets/
  96. siteverification/
  97. spectrum/
  98. sqladmin/
  99. storage/
  100. storagetransfer/
  101. tagmanager/
  102. taskqueue/
  103. tasks/
  104. toolresults/
  105. translate/
  106. transport/
  107. urlshortener/
  108. vision/
  109. webfonts/
  110. webmasters/
  111. youtube/
  112. youtubeanalytics/
  113. youtubereporting/
  114. .hgignore
  115. .hgtags
  116. .travis.yml
  117. api-list.json
  118. AUTHORS
  119. CONTRIBUTING.md
  120. CONTRIBUTORS
  121. GettingStarted.md
  122. key.json.enc
  123. LICENSE
  124. Makefile
  125. NOTES
  126. README.md
  127. TODO
README.md

Google APIs Client Library for Go

Status

Build Status

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.

Announcement email:

Getting started documentation:

In summary:

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

For docs, see e.g.:

The package of a given import is the second-to-last component, before the version number.

For examples, see:

For support, use the golang-nuts@ mailing list:

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 (
        "golang.org/x/net/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.