commit | bb198ac8a40e08503277ebd527a8898bbfbe27fb | [log] [tgz] |
---|---|---|
author | Dave Day <djd@golang.org> | Fri Aug 26 15:36:07 2016 +1000 |
committer | Dave Day <djd@golang.org> | Tue Aug 30 00:53:32 2016 +0000 |
tree | cb8b5c8141cf19c8d7869c6171450e0115de770c | |
parent | 93f710e7c7e7f084a7043ec18aab7359e7626811 [diff] |
googleapi: use RawPath, not Opaque, for template expansion Historically the google-api-go-client has had trouble sending certain characters in paths without the Go standard library (net/url and net/http packages) double escaping or escaping in an unexpected manner (for example, space encoding in issue #64). As a workaround, we started escaping the URL manually and using url.Opaque (for example, 02cfcab and 5c258d4). This mostly works but has problems with HTTP/2 (golang/go#16847). In Go 1.5, the URL struct introduced the RawPath field which was more suitable for this task: if RawPath is provided and is a valid escaping of Path, then the url package will use it as the value of EscapedPath (and EscapedPath is then subsequently used when constructing HTTP requests etc.). This commit changes uritemplates.Expand to return both the unescaped and escaped forms of the the template expansion. This allows us to fill in both url.Path and url.RawPath in a way that satisfies the criteria for url.EscapedPath to function correctly. Issue #161. Change-Id: I51e54e18f198b6465a6d032b1072282bf3d2f9ce Reviewed-on: https://code-review.googlesource.com/7110 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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 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.