oauth2, oauth2/google: add, use ReuseTokenSource
Token caching is now done whenever you make a Client, and ReuseTokenSource is exported from the oauth2 package and used by the Google TokenSources (Compute and App Engine). Token.Expired is now Token.Valid, and works on nil receivers. Some other wording cleanups in the process. All tests pass. App Engine should pass, but is untested. Change-Id: Ibe1d2599ac3ccfe9b399b1672f74bb24cfc8d311 Reviewed-on: https://go-review.googlesource.com/2195 Reviewed-by: Burcu Dogan <jbd@google.com>
This commit is contained in:
@@ -50,7 +50,6 @@ func ExampleConfig() {
|
||||
}
|
||||
|
||||
func ExampleJWTConfig() {
|
||||
var initialToken *oauth2.Token // nil means no initial token
|
||||
conf := &oauth2.JWTConfig{
|
||||
Email: "xxx@developer.com",
|
||||
// The contents of your RSA private key or your PEM file
|
||||
@@ -67,6 +66,6 @@ func ExampleJWTConfig() {
|
||||
}
|
||||
// Initiate an http.Client, the following GET request will be
|
||||
// authorized and authenticated on the behalf of user@example.com.
|
||||
client := conf.Client(oauth2.NoContext, initialToken)
|
||||
client := conf.Client(oauth2.NoContext)
|
||||
client.Get("...")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user