tree: 6264949465a1c95bc15a2d9291694d215c99d47c [path history] [tgz]
  1. .gitignore
  2. .hgtags
  3. .travis.yml
  9. NOTES
  11. TODO
  12. api-list.json
  13. cloudbuild/
  14. cloudtrace/
  15. compute/
  16. container/
  17. dns/
  18. gensupport/
  19. googleapi/
  20. iam/
  21. internal/
  22. iterator/
  23. key.json.enc
  24. option/
  25. storage/
  26. support/
  27. transport/

Google APIs Client Library for Go

Getting Started

$ go get
$ go get
$ go get
... etc ...

and using:

package main

import (


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


Build 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.

This client library is supported, but in maintenance mode only. We are fixing necessary bugs and adding essential features to ensure this library continues to meet your needs for accessing Google APIs. Non-critical issues will be closed. Any issue may be reopened if it is causing ongoing problems.

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., “”).

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 package. To use them, add the following import:

import ""

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 (

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: package documentation.