forked from Mirrors/oauth2
Rename getAppEngineTokenSource and appEngineTokenSource
appEngineTokenSource -> gaeTokenSource getAppEngineTokenSource -> appEngineTokenSource
This commit is contained in:
parent
0f03d90764
commit
75f52a8d59
|
@ -34,5 +34,5 @@ var appengineAppIDFunc func(c context.Context) string
|
||||||
// context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource,
|
// context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource,
|
||||||
// which DefaultTokenSource will use in this case) instead.
|
// which DefaultTokenSource will use in this case) instead.
|
||||||
func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
||||||
return getAppEngineTokenSource(ctx, scope...)
|
return appEngineTokenSource(ctx, scope...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,10 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See comment on AppEngineTokenSource in appengine.go.
|
// See comment on AppEngineTokenSource in appengine.go.
|
||||||
func getAppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
func appEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
||||||
scopes := append([]string{}, scope...)
|
scopes := append([]string{}, scope...)
|
||||||
sort.Strings(scopes)
|
sort.Strings(scopes)
|
||||||
return &appEngineTokenSource{
|
return &gaeTokenSource{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
scopes: scopes,
|
scopes: scopes,
|
||||||
key: strings.Join(scopes, " "),
|
key: strings.Join(scopes, " "),
|
||||||
|
@ -45,13 +45,13 @@ type tokenLock struct {
|
||||||
t *oauth2.Token
|
t *oauth2.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
type appEngineTokenSource struct {
|
type gaeTokenSource struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
scopes []string
|
scopes []string
|
||||||
key string // to aeTokens map; space-separated scopes
|
key string // to aeTokens map; space-separated scopes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ts *appEngineTokenSource) Token() (*oauth2.Token, error) {
|
func (ts *gaeTokenSource) Token() (*oauth2.Token, error) {
|
||||||
aeTokensMu.Lock()
|
aeTokensMu.Lock()
|
||||||
tok, ok := aeTokens[ts.key]
|
tok, ok := aeTokens[ts.key]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
@ -25,7 +25,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// See comment on AppEngineTokenSource in appengine.go.
|
// See comment on AppEngineTokenSource in appengine.go.
|
||||||
func getAppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
func appEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
|
||||||
once.Do(logFunc)
|
once.Do(logFunc)
|
||||||
return ComputeTokenSource("")
|
return ComputeTokenSource("")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue