@@ -6,25 +6,24 @@ package google
66
77import (
88 "context"
9- "time"
9+ "log"
10+ "sync"
1011
1112 "golang.org/x/oauth2"
1213)
1314
14- // Set at init time by appengine_gen1.go. If nil, we're not on App Engine standard first generation (<= Go 1.9) or App Engine flexible.
15- var appengineTokenFunc func (c context.Context , scopes ... string ) (token string , expiry time.Time , err error )
16-
17- // Set at init time by appengine_gen1.go. If nil, we're not on App Engine standard first generation (<= Go 1.9) or App Engine flexible.
18- var appengineAppIDFunc func (c context.Context ) string
15+ var logOnce sync.Once // only spam about deprecation once
1916
2017// AppEngineTokenSource returns a token source that fetches tokens from either
2118// the current application's service account or from the metadata server,
2219// depending on the App Engine environment. See below for environment-specific
2320// details. If you are implementing a 3-legged OAuth 2.0 flow on App Engine that
2421// involves user accounts, see oauth2.Config instead.
2522//
26- // First generation App Engine runtimes (<= Go 1.9):
27- // AppEngineTokenSource returns a token source that fetches tokens issued to the
23+ // The current version of this library requires at least Go 1.17 to build,
24+ // so first generation App Engine runtimes (<= Go 1.9) are unsupported.
25+ // Previously, on first generation App Engine runtimes, AppEngineTokenSource
26+ // returned a token source that fetches tokens issued to the
2827// current App Engine application's service account. The provided context must have
2928// come from appengine.NewContext.
3029//
@@ -34,5 +33,8 @@ var appengineAppIDFunc func(c context.Context) string
3433// context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource,
3534// which DefaultTokenSource will use in this case) instead.
3635func AppEngineTokenSource (ctx context.Context , scope ... string ) oauth2.TokenSource {
37- return appEngineTokenSource (ctx , scope ... )
36+ logOnce .Do (func () {
37+ log .Print ("google: AppEngineTokenSource is deprecated on App Engine standard second generation runtimes (>= Go 1.11) and App Engine flexible. Please use DefaultTokenSource or ComputeTokenSource." )
38+ })
39+ return ComputeTokenSource ("" )
3840}
0 commit comments