Auto-generated Google APIs for Go.

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

Go Reference

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.

Owner
Google APIs
Clients for Google APIs and tools that help produce them.
Google APIs
Comments
  • Add ImpersonatedCredentials

    Add ImpersonatedCredentials

    Add capability to impersonate a service account.

    This feature is idential to the capability existing in

    the original PR against oauth2 was abandoned on suggestion it gets added to this repo ref: https://github.com/golang/oauth2/issues/336

    as a folwlup, i created https://github.com/googleapis/google-api-go-client/pull/337 againts this repo but on request from the maintainers here back then, they would implement it separately somehow. Its not implemented yet so are we ok to reopen the the PR 337?

    If so, the sample usage looks like https://gist.github.com/salrashid123/7994be642c466844f85e2f2c68a5dec9

  • grpc.RoundRobin and grpc.WithBalancer no longer exist

    grpc.RoundRobin and grpc.WithBalancer no longer exist

    We are using this library and seeing these errors:

    ../google.golang.org/api/option/option.go:153:14: undefined: grpc.RoundRobin ../google.golang.org/api/option/option.go:154:42: undefined: grpc.WithBalancer

    Sounds like gRPC removed these legacy APIs: https://github.com/grpc/grpc-go/commit/336cf8d76145dc5ebd517fd9c19e14c6822450b3

  • drive/v3 Files.Update can't remove properties or appProperties

    drive/v3 Files.Update can't remove properties or appProperties

    based on the comment of File.AppProperties: // Entries with null values are cleared in update and copy requests. AppProperties map[string]string json:"appProperties,omitempty"

    Sadly AppProperties is a map of string, and a string can't be nil (but it can be empty). There are other fields in File to manage empty fields, called ForceSendFields and NullFields, but they only work for the top level fields in File, and doesn't work recursively in Properties or AppProperties.

  • can't build on go1.11-1.11.3 because of

    can't build on go1.11-1.11.3 because of "go 1.12" declaration in go.mod

    Upgrading to go 1.12 broke compatibility with google functions, which only supports 1.11. I get the following error trying to deploy a golang google function using this library (which is, in turn used by google's bigquery library. I'm going to try to downgrade to an earlier version

    Deployment failure:
    Build failed: go: finding cloud.google.com/go/bigquery latest
    go: finding cloud.google.com/go/functions/metadata latest
    go: finding cloud.google.com/go v0.37.1
    go: downloading cloud.google.com/go v0.37.1
    go: finding github.com/googleapis/gax-go/v2 v2.0.4
    go: finding github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
    go: finding golang.org/x/tools v0.0.0-20190312170243-e65039ee4138
    go: finding golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
    go: finding golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
    go: finding google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19
    go: finding golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f
    go: finding google.golang.org/api v0.2.0
    go: finding golang.org/x/build v0.0.0-20190314133821-5284462c4bec
    go: finding golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
    go: finding google.golang.org/appengine v1.4.0
    go: finding golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
    go: finding golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
    go: finding golang.org/x/tools v0.0.0-20190226205152-f727befe758c
    go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
    go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
    go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
    go: downloading google.golang.org/api v0.2.0
    go: downloading google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19
    go: downloading github.com/googleapis/gax-go v2.0.0+incompatible
    go: downloading github.com/hashicorp/golang-lru v0.5.0
    go: downloading github.com/googleapis/gax-go/v2 v2.0.4
    go: downloading golang.org/x/net v0.0.0-20190311183353-d8887717615a
    go: downloading golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
    go: downloading golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
    go build google.golang.org/api/googleapi/internal/uritemplates: module requires Go 1.12
    go build google.golang.org/api/iterator: module requires Go 1.12
    go build google.golang.org/api/internal: module requires Go 1.12
    go build google.golang.org/api/googleapi/transport: module requires Go 1.12
    go build google.golang.org/api/transport/http/internal/propagation: module requires Go 1.12
    
  • sqladmin/v1beta4 Incorrect field name while filtering

    sqladmin/v1beta4 Incorrect field name while filtering

    How to filter the database version field when listing the instances? I used DATABASE_VERSION:MYSQL* and it returned an error saying that DATABASE_VERSION field does not exist

  • Cannot deploy Cloud Run using API: badRequest INVALID_ARGUMENT (no further details provided)

    Cannot deploy Cloud Run using API: badRequest INVALID_ARGUMENT (no further details provided)

    Client

    Run-v1: google.golang.org/api/run/v1

    Describe Your Environment

    • JetBrains GoLand IDE
    • go 1.13.4
    • google.golang.org/api v0.15.0 (have also tried with google.golang.org/api v0.14.0, same result)
    • Google Cloud Run

    Expected Behavior

    Ability to deploy a new Cloud Run Service object using the golang library.

    Actual Behavior

    Attempting to deploy a new Cloud Run service returns a badRequest response, with status INVALID_ARGUMENT despite basing the Service model on an existing, manually created service using:

    gcloud run services describe existing-service1 --format=json --project=MY_PROJECT --platform=managed

    *** Click here for the code used to attempt the deployment ***

    Error:

    {
      "error": {
        "code": 400,
        "message": "The request has errors",
        "errors": [
          {
            "message": "The request has errors",
            "domain": "global",
            "reason": "badRequest"
          }
        ],
        "status": "INVALID_ARGUMENT"
      }
    }
    

    Happy to supply any further info if needed?

  • Go get gensupport broken

    Go get gensupport broken

    This can be replicated by doing

    go get -d "google.golang.org/api/gensupport"
    

    with output:

    package google.golang.org/api/gensupport: cannot find package "google.golang.org/api/gensupport" in any of:
    	/usr/local/go/src/google.golang.org/api/gensupport (from $GOROOT)
    	/home/username/go/src/google.golang.org/api/gensupport (from $GOPATH)
    

    Here the output while running

    go get -v  ./...
    
    Fetching https://google.golang.org/api/gensupport?go-get=1
    Parsing meta tags from https://google.golang.org/api/gensupport?go-get=1 (status code 200)
    get "google.golang.org/api/gensupport": found meta tag get.metaImport{Prefix:"google.golang.org/api", VCS:"git", RepoRoot:"https://code.googlesource.com/google-api-go-client"} at https://google.golang.org/api/gensupport?go-get=1
    get "google.golang.org/api/gensupport": verifying non-authoritative meta tag
    Fetching https://google.golang.org/api?go-get=1
    Parsing meta tags from https://google.golang.org/api?go-get=1 (status code 200)
    google.golang.org/api (download)
    package google.golang.org/api/gensupport: cannot find package "google.golang.org/api/gensupport" in any of:
    	/usr/local/go/src/google.golang.org/api/gensupport (from $GOROOT)
    	/home/username/go/src/google.golang.org/api/gensupport (from $GOPATH)
    
  • Compute request failures due to oauth2

    Compute request failures due to oauth2

    When performing compute api actions we often see transitory errors reported due to oauth2 issues e.g.

    Get https://www.googleapis.com/compute/v1/projects/XXXX/regions/us-central1?alt=json: oauth2: cannot fetch token: Post https://accounts.google.com/o/oauth2/token: write tcp XX.XX.XX.XXX:57793->216.58.199.45:443: write: socket is not connected
    

    It seems like this should be handled internally and not result in an API request failure.

  • Some page streaming methods have no `Pages` method

    Some page streaming methods have no `Pages` method

    I believe this only happens when the response has a nextPageToken field, but no pageToken field.

    For example, cloudresourcemanager.organizations.search has a page streaming response, but the Go client library doesn't implement it as one: https://godoc.org/google.golang.org/api/cloudresourcemanager/v1#OrganizationsSearchCall

  • Datastore: Indexed as false doesn't get transmitted (i.e. remains true gcd side)

    Datastore: Indexed as false doesn't get transmitted (i.e. remains true gcd side)

    peterke on 14 Jan 2014 at 10:18:

    Setting the Indexed field of a property to false will result in it being 
    ommited from the generated JSON request (due to it being defined as 
    "omitempty"), and as such, the default "indexed" value will be used server 
    side, which will be true most of the time (e.g. for strings).
    
    Removing the omitempty solves the issue:
    Indexed bool `json:"indexed"`
    
    What version of the product are you using? On what operating system?
    datastore v1beta2
    
  • feat: add impersonate pacakge

    feat: add impersonate pacakge

    This package is used for creating a impersonated TokenSource. This TokenSource can then be passed into any client or API that accepts a client option. This package provides support for three types of impersonation:

    1. A service account impersonating another service account.
    2. A service account impersonating another service account as an admin user -- a pattern used with domain wide delegation.
    3. A service account creating an impersonated ID token.

    Fixes: #652 Fixes: #777 Fixes: #731 Updates: #378

  • chore(main): release 0.107.0

    chore(main): release 0.107.0

  • Unable to create a custom domain using Firebase Hosting API

    Unable to create a custom domain using Firebase Hosting API

    I'm trying to automate custom domain creation process in Firebase Hosting, I am using Go library, but it doesn't work, I am also happy to know about plain REST alternative. I always get this error:

    googleapi: Error 400: Domain test1.example.com not associated with project, failedPrecondition exit status 1
    

    Go code using Go library:

    firebase, _ := firebasehosting.NewService(context.Background())
    
    domain := &firebasehosting.Domain{
        DomainName: "test1.example.com",
        Site:       "dashboard-v1-staging",
    }
    
    createCall := firebase.Projects.Sites.Domains.Create("projects/ID/sites/ID", domain)
    _, err = createCall.Do()
    if err != nil && !googleapi.IsNotModified(err) {
        log.Println(err)
        os.Exit(1)
    }
    
  • Apigee UpdateDeveloperAppKeyApiProduct returns 502

    Apigee UpdateDeveloperAppKeyApiProduct returns 502

    Environment details

    • Programming language: GO
    • OS: mac os / linux
    • Language runtime version: 1.19
    • Package version: google.golang.org/api v0.103.0 apigee v1

    Steps to reproduce

    1. Run our go app calling the method as follows:
    		UpdateDeveloperAppKeyApiProduct(
    			"organizations/<$project_id>/developers/<$developer_email>/apps/<$app>/keys/<$key_id>/apiproducts/<$product>",
    		).
    		Action('approve').
    		Do()
    
    1. Results in 502 response as follows:
    googleapi: got HTTP response code 502 with body: <!DOCTYPE html>
    <html lang=en>
      <meta charset=utf-8>
      <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
      <title>Error 502 (Server Error)!!1</title>
      <style>
        *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
      </style>
      <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
      <p><b>502.</b> <ins>That’s an error.</ins>
      <p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.  <ins>That’s all we know.</ins>
    
    1. Calling the api method does work and the api key is approved / revoked as expected, however our app exits with failure due to the 502 error
    2. Calling the endpoint via curl results in a 200 response.
  • Memory Leak from time.After

    Memory Leak from time.After

    Thanks for stopping by to let us know something could be better!

    PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

    Is this a client library issue or a product issue? We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers.

    If the support paths suggested above still do not result in a resolution, please provide the following details.

    Environment details

    • Programming language: Golang
    • OS: MacOS
    • Language runtime version: 1.18
    • Package version: ?

    Steps to reproduce

    https://github.com/googleapis/google-api-go-client/blob/25e2e243ef14bc3ff3ecd47ac5172b87346a320f/internal/gensupport/resumable.go#L196

    https://github.com/googleapis/google-api-go-client/blob/25e2e243ef14bc3ff3ecd47ac5172b87346a320f/internal/gensupport/resumable.go#L208

    There are other places that use time.After. If using with long retryDeadline, the memory usage keeps increasing.

    Making sure to follow these steps will guarantee the quickest resolution possible.

    Thanks!

Sync your bank transactions with google sheets using Open Banking APIs

this is a markdown version of the copy on the site landing page: https://youneedaspreadsheet.com You need a spreadsheet ?? Get on top of your finances

Jul 22, 2022
Correct the timestamp of photo/video of Google Photo from Google takeout

Correct Timestamp of Google Photo from Google Takeout Development Environment: Ubuntu 20.04 Go 1.17 Usage Require Go 1.16 or later to build. go build

Sep 9, 2022
A fully-featured OpenAPI generated HubSpot client for Go
A fully-featured OpenAPI generated HubSpot client for Go

This is a HubSpot Go client generated using openapi-generator. It includes packages for every OpenAPI spec listed in HubSpot's API directory. Installi

Dec 31, 2022
User-Generated Content Articles 📝

?? Community Articles A library of technical articles on anything code. Written by the Codecademy community. What are Community Articles? Community ar

Oct 23, 2022
Spawning up Decoy Server in case of any fraudulent activity and directing the intruder towards the decoy. Auto Killing the decoy if it is idle for too long.
Spawning up Decoy Server in case of any fraudulent activity and directing the intruder towards the decoy. Auto Killing the decoy if it is idle for too long.

SecureX Spawning up Decoy Server in case of any fraudulent activity and directing the intruder towards the decoy. Auto Killing the decoy if it is idle

Jul 9, 2022
A Github Action to auto approve pull requests that contain only document reviews.

Approve documentation review A Github Action to auto approve pull requests that contain only document reviews. The Cloud Platform team have a document

Dec 23, 2021
Go library to access geocoding and reverse geocoding APIs

GeoService in Go Code Coverage A geocoding service developed in Go's way, idiomatic and elegant, not just in golang. This product is designed to open

Dec 23, 2022
A golang client for the Twitch v3 API - public APIs only (for now)

go-twitch Test CLIENT_ID="<my client ID>" go test -v -cover Usage Example File: package main import ( "log" "os" "github.com/knspriggs/go-twi

Sep 27, 2022
Twilight is an unofficial Golang SDK for Twilio APIs
Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs. Twilight was born as a result of my inability to spell Twilio correctly. I searched for a Twillio Golang client library and couldn’t find any, I decided to build one. Halfway through building this, I realized I had spelled Twilio as Twillio when searching for a client library on Github.

Jul 2, 2021
The MinIO Admin Go Client SDK provides APIs to manage MinIO services

Golang Admin Client API Reference The MinIO Admin Golang Client SDK provides APIs to manage MinIO services. This quickstart guide will show you how to

Dec 30, 2022
lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin to AWS Lambda and Amazon API Gateway.

aws-lambda-go-api-proxy makes it easy to run Golang APIs written with frameworks such as Gin with AWS Lambda and Amazon API Gateway.

Jan 6, 2023
"there" also called "GoThere" aims to be a simple Go Library to reduce redundant code for REST APIs.

there "there" also called "GoThere" aims to be a simple Go Library to reduce redundant code for REST APIs. Despite the existence of the other librarie

Dec 25, 2022
Go API Client for NASA's Open APIs

Go Client for Nasa Open APIs Description The Go Client for Nasa Open APIs is a Go Client for the following Nasa Open APIs: APOD: Astronomy Picture of

Sep 24, 2021
Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs

PnPjs is a fluent JavaScript API for consuming SharePoint and Microsoft Graph REST APIs in a type-safe way. You can use it with SharePoint Framework,

Dec 23, 2022
Http apis with AWS CDK for Go

Http apis with AWS CDK for Go Blog: https://harshq.medium.com/building-apps-with-aws-sdk-for-golang-api-gateway-and-lambda-b254858b1d71 Useful command

Jan 4, 2022
The task given by Appointy completed to develop APIs for a basic version of Instagram.

✨ Instagram APIs ✨ The task given by Appointy completed to develop APIs for a basic version of Instagram. Create an User Get User by Id Create a Post

Oct 9, 2021
Apis para la administracion de notifiaciones, utilizando servicios como AWS SNS y AWS SQS

notificacion_api Servicio para envío de notificaciónes por difusión en AWS SNS Especificaciones Técnicas Tecnologías Implementadas y Versiones Golang

Jan 7, 2022
This repo introduces a simple server, which provided some APIs for search DAS account's records or reverse records

Prerequisites Install Usage Others Das-Account-Indexer This repo introduces a simple server, which provided some APIs for search DAS account's records

Dec 13, 2022
Simple-api - Create Simple `Hello World` APIs from Various Programming Languages

simple-api Create Simple `Hello World` APIs from Various Programming Languages.

Jan 18, 2022