mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Added goauth2 and the google api client.
This commit is contained in:
parent
45397c46cc
commit
23e736c8e1
4
third_party/deps.sh
vendored
4
third_party/deps.sh
vendored
@ -1,11 +1,15 @@
|
|||||||
TOP_PACKAGES="
|
TOP_PACKAGES="
|
||||||
github.com/coreos/go-etcd/etcd
|
github.com/coreos/go-etcd/etcd
|
||||||
github.com/fsouza/go-dockerclient
|
github.com/fsouza/go-dockerclient
|
||||||
|
code.google.com/p/goauth2/compute/serviceaccount
|
||||||
|
code.google.com/p/goauth2/oauth
|
||||||
|
code.google.com/p/google-api-go-client/compute/v1
|
||||||
"
|
"
|
||||||
|
|
||||||
DEP_PACKAGES="
|
DEP_PACKAGES="
|
||||||
gopkg.in/v1/yaml
|
gopkg.in/v1/yaml
|
||||||
bitbucket.org/kardianos/osext
|
bitbucket.org/kardianos/osext
|
||||||
|
code.google.com/p/google-api-go-client/googleapi
|
||||||
github.com/coreos/go-log/log
|
github.com/coreos/go-log/log
|
||||||
github.com/coreos/go-systemd/journal
|
github.com/coreos/go-systemd/journal
|
||||||
"
|
"
|
||||||
|
BIN
third_party/src/code.google.com/p/goauth2/.hg/00changelog.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/00changelog.i
vendored
Normal file
Binary file not shown.
1
third_party/src/code.google.com/p/goauth2/.hg/branch
vendored
Normal file
1
third_party/src/code.google.com/p/goauth2/.hg/branch
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
default
|
2
third_party/src/code.google.com/p/goauth2/.hg/cache/branchheads-served
vendored
Normal file
2
third_party/src/code.google.com/p/goauth2/.hg/cache/branchheads-served
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
696c088491246273e92442aa66b5281e5bb34faa 68
|
||||||
|
696c088491246273e92442aa66b5281e5bb34faa default
|
4
third_party/src/code.google.com/p/goauth2/.hg/cache/tags
vendored
Normal file
4
third_party/src/code.google.com/p/goauth2/.hg/cache/tags
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
68 696c088491246273e92442aa66b5281e5bb34faa 376d5fb6b2d758667877a62ee81b204d35dc2e03
|
||||||
|
|
||||||
|
379476c9e05c5275356e0a82ca079e61869e9192 release
|
||||||
|
4ee7c273e92e663ef8dc0c476d395350a586ad75 weekly
|
BIN
third_party/src/code.google.com/p/goauth2/.hg/dirstate
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/dirstate
vendored
Normal file
Binary file not shown.
2
third_party/src/code.google.com/p/goauth2/.hg/hgrc
vendored
Normal file
2
third_party/src/code.google.com/p/goauth2/.hg/hgrc
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[paths]
|
||||||
|
default = https://code.google.com/p/goauth2
|
4
third_party/src/code.google.com/p/goauth2/.hg/requires
vendored
Normal file
4
third_party/src/code.google.com/p/goauth2/.hg/requires
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
dotencode
|
||||||
|
fncache
|
||||||
|
revlogv1
|
||||||
|
store
|
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/00changelog.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/00changelog.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/00manifest.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/00manifest.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_a_u_t_h_o_r_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_a_u_t_h_o_r_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_c_o_n_t_r_i_b_u_t_o_r_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_c_o_n_t_r_i_b_u_t_o_r_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_l_i_c_e_n_s_e.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_l_i_c_e_n_s_e.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_p_a_t_e_n_t_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_p_a_t_e_n_t_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_r_e_a_d_m_e.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/_r_e_a_d_m_e.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/appengine/serviceaccount/cache.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/appengine/serviceaccount/cache.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/compute/serviceaccount/serviceaccount.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/compute/serviceaccount/serviceaccount.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/lib/codereview/codereview.cfg.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/lib/codereview/codereview.cfg.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/_makefile.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/_makefile.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/_makefile.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/_makefile.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/buzz.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/buzz.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/oauthreq.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/example/oauthreq.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/example/example.pem.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/example/example.pem.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/example/main.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/example/main.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/jwt.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/jwt.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/jwt__test.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/jwt/jwt__test.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/oauth.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/oauth.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/oauth__test.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/oauth/oauth__test.go.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/~2ehgignore.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/~2ehgignore.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/~2ehgtags.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/data/~2ehgtags.i
vendored
Normal file
Binary file not shown.
22
third_party/src/code.google.com/p/goauth2/.hg/store/fncache
vendored
Normal file
22
third_party/src/code.google.com/p/goauth2/.hg/store/fncache
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
data/compute/serviceaccount/serviceaccount.go.i
|
||||||
|
data/AUTHORS.i
|
||||||
|
data/CONTRIBUTORS.i
|
||||||
|
data/oauth/oauth.go.i
|
||||||
|
data/oauth/jwt/example/main.go.i
|
||||||
|
data/appengine/serviceaccount/cache.go.i
|
||||||
|
data/oauth/example/buzz.go.i
|
||||||
|
data/oauth/jwt/jwt.go.i
|
||||||
|
data/lib/codereview/codereview.cfg.i
|
||||||
|
data/oauth/jwt/example/example.client_secrets.json.i
|
||||||
|
data/LICENSE.i
|
||||||
|
data/appengine/serviceaccount/serviceaccount.go.i
|
||||||
|
data/oauth/oauth_test.go.i
|
||||||
|
data/.hgignore.i
|
||||||
|
data/oauth/jwt/example/example.pem.i
|
||||||
|
data/oauth/Makefile.i
|
||||||
|
data/oauth/example/Makefile.i
|
||||||
|
data/PATENTS.i
|
||||||
|
data/.hgtags.i
|
||||||
|
data/README.i
|
||||||
|
data/oauth/jwt/jwt_test.go.i
|
||||||
|
data/oauth/example/oauthreq.go.i
|
0
third_party/src/code.google.com/p/goauth2/.hg/store/phaseroots
vendored
Normal file
0
third_party/src/code.google.com/p/goauth2/.hg/store/phaseroots
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/undo
vendored
Normal file
BIN
third_party/src/code.google.com/p/goauth2/.hg/store/undo
vendored
Normal file
Binary file not shown.
0
third_party/src/code.google.com/p/goauth2/.hg/store/undo.phaseroots
vendored
Normal file
0
third_party/src/code.google.com/p/goauth2/.hg/store/undo.phaseroots
vendored
Normal file
0
third_party/src/code.google.com/p/goauth2/.hg/undo.bookmarks
vendored
Normal file
0
third_party/src/code.google.com/p/goauth2/.hg/undo.bookmarks
vendored
Normal file
1
third_party/src/code.google.com/p/goauth2/.hg/undo.branch
vendored
Normal file
1
third_party/src/code.google.com/p/goauth2/.hg/undo.branch
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
default
|
3
third_party/src/code.google.com/p/goauth2/.hg/undo.desc
vendored
Normal file
3
third_party/src/code.google.com/p/goauth2/.hg/undo.desc
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
0
|
||||||
|
pull
|
||||||
|
https://code.google.com/p/goauth2
|
0
third_party/src/code.google.com/p/goauth2/.hg/undo.dirstate
vendored
Normal file
0
third_party/src/code.google.com/p/goauth2/.hg/undo.dirstate
vendored
Normal file
1
third_party/src/code.google.com/p/goauth2/.hgignore
vendored
Normal file
1
third_party/src/code.google.com/p/goauth2/.hgignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
last-change
|
2
third_party/src/code.google.com/p/goauth2/.hgtags
vendored
Normal file
2
third_party/src/code.google.com/p/goauth2/.hgtags
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
379476c9e05c5275356e0a82ca079e61869e9192 release
|
||||||
|
4ee7c273e92e663ef8dc0c476d395350a586ad75 weekly
|
3
third_party/src/code.google.com/p/goauth2/AUTHORS
vendored
Normal file
3
third_party/src/code.google.com/p/goauth2/AUTHORS
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# This source code refers to The Go Authors for copyright purposes.
|
||||||
|
# The master list of authors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/AUTHORS.
|
3
third_party/src/code.google.com/p/goauth2/CONTRIBUTORS
vendored
Normal file
3
third_party/src/code.google.com/p/goauth2/CONTRIBUTORS
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# This source code was written by the Go contributors.
|
||||||
|
# The master list of contributors is in the main Go distribution,
|
||||||
|
# visible at http://tip.golang.org/CONTRIBUTORS.
|
27
third_party/src/code.google.com/p/goauth2/LICENSE
vendored
Normal file
27
third_party/src/code.google.com/p/goauth2/LICENSE
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) 2009 The goauth2 Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
third_party/src/code.google.com/p/goauth2/PATENTS
vendored
Normal file
22
third_party/src/code.google.com/p/goauth2/PATENTS
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Additional IP Rights Grant (Patents)
|
||||||
|
|
||||||
|
"This implementation" means the copyrightable works distributed by
|
||||||
|
Google as part of the goauth2 project.
|
||||||
|
|
||||||
|
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||||
|
no-charge, royalty-free, irrevocable (except as stated in this section)
|
||||||
|
patent license to make, have made, use, offer to sell, sell, import,
|
||||||
|
transfer and otherwise run, modify and propagate the contents of this
|
||||||
|
implementation of Go, where such license applies only to those patent
|
||||||
|
claims, both currently owned or controlled by Google and acquired in
|
||||||
|
the future, licensable by Google that are necessarily infringed by this
|
||||||
|
implementation of Go. This grant does not include claims that would be
|
||||||
|
infringed only as a consequence of further modification of this
|
||||||
|
implementation. If you or your agent or exclusive licensee institute or
|
||||||
|
order or agree to the institution of patent litigation against any
|
||||||
|
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
||||||
|
that this implementation of Go or any code incorporated within this
|
||||||
|
implementation of Go constitutes direct or contributory patent
|
||||||
|
infringement, or inducement of patent infringement, then any patent
|
||||||
|
rights granted to you under this License for this implementation of Go
|
||||||
|
shall terminate as of the date such litigation is filed.
|
7
third_party/src/code.google.com/p/goauth2/README
vendored
Normal file
7
third_party/src/code.google.com/p/goauth2/README
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
This is the repository for goauth2; an OAuth 2.0 client library for Go.
|
||||||
|
|
||||||
|
To contribute, follow the Go Programming Language's contribution process:
|
||||||
|
http://golang.org/doc/contribute.html
|
||||||
|
Except use the goauth2 repository instead of the go repo.
|
||||||
|
|
||||||
|
Contact Andrew Gerrand <adg@golang.org> with any enquiries.
|
42
third_party/src/code.google.com/p/goauth2/appengine/serviceaccount/cache.go
vendored
Normal file
42
third_party/src/code.google.com/p/goauth2/appengine/serviceaccount/cache.go
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2013 The goauth2 Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build appengine
|
||||||
|
|
||||||
|
package serviceaccount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"appengine"
|
||||||
|
"appengine/memcache"
|
||||||
|
|
||||||
|
"code.google.com/p/goauth2/oauth"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cache implementss TokenCache using memcache to store AccessToken
|
||||||
|
// for the application service account.
|
||||||
|
type cache struct {
|
||||||
|
Context appengine.Context
|
||||||
|
Key string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m cache) Token() (*oauth.Token, error) {
|
||||||
|
item, err := memcache.Get(m.Context, m.Key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &oauth.Token{
|
||||||
|
AccessToken: string(item.Value),
|
||||||
|
Expiry: time.Now().Add(item.Expiration),
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m cache) PutToken(tok *oauth.Token) error {
|
||||||
|
return memcache.Set(m.Context, &memcache.Item{
|
||||||
|
Key: m.Key,
|
||||||
|
Value: []byte(tok.AccessToken),
|
||||||
|
Expiration: tok.Expiry.Sub(time.Now()),
|
||||||
|
})
|
||||||
|
}
|
133
third_party/src/code.google.com/p/goauth2/appengine/serviceaccount/serviceaccount.go
vendored
Normal file
133
third_party/src/code.google.com/p/goauth2/appengine/serviceaccount/serviceaccount.go
vendored
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// Copyright 2013 The goauth2 Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build appengine
|
||||||
|
|
||||||
|
// The serviceaccount package provides support for making
|
||||||
|
// OAuth2-authorized HTTP requests from App Engine using service
|
||||||
|
// accounts.
|
||||||
|
//
|
||||||
|
// See: https://developers.google.com/appengine/docs/go/reference#AccessToken
|
||||||
|
//
|
||||||
|
// Example usage:
|
||||||
|
//
|
||||||
|
// c := appengine.NewContext()
|
||||||
|
// client, err := serviceaccount.NewClient(c, "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/bigquery")
|
||||||
|
// if err != nil {
|
||||||
|
// c.Errorf("failed to create service account client: %q", err)
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// client.Post("https://www.googleapis.com/compute/...", ...)
|
||||||
|
// client.Post("https://www.googleapis.com/bigquery/...", ...)
|
||||||
|
//
|
||||||
|
package serviceaccount
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"appengine"
|
||||||
|
"appengine/urlfetch"
|
||||||
|
|
||||||
|
"code.google.com/p/goauth2/oauth"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewClient returns an *http.Client authorized for the
|
||||||
|
// given scopes with the service account owned by the application.
|
||||||
|
// Tokens are cached in memcache until they expire.
|
||||||
|
func NewClient(c appengine.Context, scopes ...string) (*http.Client, error) {
|
||||||
|
t := &transport{
|
||||||
|
Context: c,
|
||||||
|
Scopes: scopes,
|
||||||
|
Transport: &urlfetch.Transport{
|
||||||
|
Context: c,
|
||||||
|
Deadline: 0,
|
||||||
|
AllowInvalidServerCertificate: false,
|
||||||
|
},
|
||||||
|
TokenCache: &cache{
|
||||||
|
Context: c,
|
||||||
|
Key: "goauth2_serviceaccount_" + strings.Join(scopes, "_"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// Get the initial access token.
|
||||||
|
if err := t.FetchToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &http.Client{
|
||||||
|
Transport: t,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// transport is an oauth.Transport with a custom Refresh and RoundTrip implementation.
|
||||||
|
type transport struct {
|
||||||
|
*oauth.Token
|
||||||
|
Context appengine.Context
|
||||||
|
Scopes []string
|
||||||
|
Transport http.RoundTripper
|
||||||
|
TokenCache oauth.Cache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *transport) Refresh() error {
|
||||||
|
// Get a new access token for the application service account.
|
||||||
|
tok, expiry, err := appengine.AccessToken(t.Context, t.Scopes...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
t.Token = &oauth.Token{
|
||||||
|
AccessToken: tok,
|
||||||
|
Expiry: expiry,
|
||||||
|
}
|
||||||
|
if t.TokenCache != nil {
|
||||||
|
// Cache the token and ignore error (as we can always get a new one).
|
||||||
|
t.TokenCache.PutToken(t.Token)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch token from cache or generate a new one if cache miss or expired.
|
||||||
|
func (t *transport) FetchToken() error {
|
||||||
|
// Try to get the Token from the cache if enabled.
|
||||||
|
if t.Token == nil && t.TokenCache != nil {
|
||||||
|
// Ignore cache error as we can always get a new token with Refresh.
|
||||||
|
t.Token, _ = t.TokenCache.Token()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a new token using Refresh in case of a cache miss of if it has expired.
|
||||||
|
if t.Token == nil || t.Expired() {
|
||||||
|
if err := t.Refresh(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cloneRequest returns a clone of the provided *http.Request.
|
||||||
|
// The clone is a shallow copy of the struct and its Header map.
|
||||||
|
func cloneRequest(r *http.Request) *http.Request {
|
||||||
|
// shallow copy of the struct
|
||||||
|
r2 := new(http.Request)
|
||||||
|
*r2 = *r
|
||||||
|
// deep copy of the Header
|
||||||
|
r2.Header = make(http.Header)
|
||||||
|
for k, s := range r.Header {
|
||||||
|
r2.Header[k] = s
|
||||||
|
}
|
||||||
|
return r2
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoundTrip issues an authorized HTTP request and returns its response.
|
||||||
|
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
|
if err := t.FetchToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// To set the Authorization header, we must make a copy of the Request
|
||||||
|
// so that we don't modify the Request we were given.
|
||||||
|
// This is required by the specification of http.RoundTripper.
|
||||||
|
newReq := cloneRequest(req)
|
||||||
|
newReq.Header.Set("Authorization", "Bearer "+t.AccessToken)
|
||||||
|
|
||||||
|
// Make the HTTP request.
|
||||||
|
return t.Transport.RoundTrip(newReq)
|
||||||
|
}
|
2
third_party/src/code.google.com/p/goauth2/lib/codereview/codereview.cfg
vendored
Normal file
2
third_party/src/code.google.com/p/goauth2/lib/codereview/codereview.cfg
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
defaultcc: golang-dev@googlegroups.com
|
||||||
|
contributors: http://go.googlecode.com/hg/CONTRIBUTORS
|
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/00changelog.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/00changelog.i
vendored
Normal file
Binary file not shown.
1
third_party/src/code.google.com/p/google-api-go-client/.hg/branch
vendored
Normal file
1
third_party/src/code.google.com/p/google-api-go-client/.hg/branch
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
default
|
3
third_party/src/code.google.com/p/google-api-go-client/.hg/cache/branchheads-served
vendored
Normal file
3
third_party/src/code.google.com/p/google-api-go-client/.hg/cache/branchheads-served
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
2ba9f0995cf0215c20ebd6de43a14d70af30fea6 111
|
||||||
|
82370a626348d2965e51305ac70a6243994c86d7 default
|
||||||
|
2ba9f0995cf0215c20ebd6de43a14d70af30fea6 default
|
4
third_party/src/code.google.com/p/google-api-go-client/.hg/cache/tags
vendored
Normal file
4
third_party/src/code.google.com/p/google-api-go-client/.hg/cache/tags
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
111 2ba9f0995cf0215c20ebd6de43a14d70af30fea6 240bf94bde841a072024e132d5d77029a0b0fbef
|
||||||
|
14 82370a626348d2965e51305ac70a6243994c86d7
|
||||||
|
|
||||||
|
b571b553f8c057cb6952ce817dfb09b6e34a8c0b release
|
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/dirstate
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/dirstate
vendored
Normal file
Binary file not shown.
2
third_party/src/code.google.com/p/google-api-go-client/.hg/hgrc
vendored
Normal file
2
third_party/src/code.google.com/p/google-api-go-client/.hg/hgrc
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[paths]
|
||||||
|
default = https://code.google.com/p/google-api-go-client
|
4
third_party/src/code.google.com/p/google-api-go-client/.hg/requires
vendored
Normal file
4
third_party/src/code.google.com/p/google-api-go-client/.hg/requires
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
dotencode
|
||||||
|
fncache
|
||||||
|
revlogv1
|
||||||
|
store
|
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/00changelog.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/00changelog.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/00manifest.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/00manifest.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_a_u_t_h_o_r_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_a_u_t_h_o_r_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_c_o_n_t_r_i_b_u_t_o_r_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_c_o_n_t_r_i_b_u_t_o_r_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_l_i_c_e_n_s_e.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_l_i_c_e_n_s_e.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_makefile.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_makefile.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_n_o_t_e_s.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_n_o_t_e_s.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_r_e_a_d_m_e.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_r_e_a_d_m_e.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_t_o_d_o.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/_t_o_d_o.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adexchangebuyer/v1/_makefile.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adexchangebuyer/v1/_makefile.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.1/adsense-gen.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.1/adsense-gen.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.2/adsense-gen.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.2/adsense-gen.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.3/adsense-gen.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.3/adsense-gen.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.4/adsense-gen.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1.4/adsense-gen.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/_makefile.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/_makefile.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/adsense-api.json.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/adsense-api.json.i
vendored
Normal file
Binary file not shown.
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/adsense-gen.go.i
vendored
Normal file
BIN
third_party/src/code.google.com/p/google-api-go-client/.hg/store/data/adsense/v1/adsense-gen.go.i
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user