commit | 314dd2c0bf3ebd592ec0d20847d27e79d0dbe8dd | [log] [tgz] |
---|---|---|
author | Tristan Colgate <tcolgate@gmail.com> | Wed Dec 14 09:25:55 2016 +0000 |
committer | Jaana Burcu Dogan <jbd@google.com> | Mon Dec 19 19:29:54 2016 +0000 |
tree | 32ce0a74fae21cedaac997b760089bc5493f361a | |
parent | 96382aa079b72d8c014eb0c50f6c223d1e6a2de0 [diff] |
golang.org/x/oauth2/jwt: Set kid to KeyID of private key Set the KeyID hint in the token header. This allows remote servers to identify the key used to sign the message. Fixes #18307 Change-Id: Ib95398079833aad6b390650b465d7b09b5f53fda Reviewed-on: https://go-review.googlesource.com/34320 Reviewed-by: Jaana Burcu Dogan <jbd@google.com>
oauth2 package contains a client implementation for OAuth 2.0 spec.
go get golang.org/x/oauth2
See godoc for further documentation and examples.
In change 96e89be (March 2015) we removed the oauth2.Context2
type in favor of the context.Context
type from the golang.org/x/net/context
package
This means its no longer possible to use the “Classic App Engine” appengine.Context
type with the oauth2
package. (You're using Classic App Engine if you import the package "appengine"
.)
To work around this, you may use the new "google.golang.org/appengine"
package. This package has almost the same API as the "appengine"
package, but it can be fetched with go get
and used on “Managed VMs” and well as Classic App Engine.
See the new appengine
package's readme for information on updating your app.
If you don't want to update your entire app to use the new App Engine packages, you may use both sets of packages in parallel, using only the new packages with the oauth2
package.
import ( "golang.org/x/net/context" "golang.org/x/oauth2" "golang.org/x/oauth2/google" newappengine "google.golang.org/appengine" newurlfetch "google.golang.org/appengine/urlfetch" "appengine" ) func handler(w http.ResponseWriter, r *http.Request) { var c appengine.Context = appengine.NewContext(r) c.Infof("Logging a message with the old package") var ctx context.Context = newappengine.NewContext(r) client := &http.Client{ Transport: &oauth2.Transport{ Source: google.AppEngineTokenSource(ctx, "scope"), Base: &newurlfetch.Transport{Context: ctx}, }, } client.Get("...") }