Address review comments

- Move AppEngineTokenSource documentation to one location
- Add file comments
- Log the deprecation message exactly once in the second generation and
  flex AppEngineTokenSource.
This commit is contained in:
Michael Traver
2018-10-31 10:49:27 -07:00
parent be148ec7a7
commit 0f03d90764
3 changed files with 39 additions and 35 deletions

View File

@@ -4,6 +4,8 @@
// +build appengine
// This file applies to App Engine first generation runtimes (<= Go 1.9).
package google
import (
@@ -21,23 +23,8 @@ func init() {
appengineAppIDFunc = appengine.AppID
}
// AppEngineTokenSource returns a token source that fetches tokens from either
// the current application's service account or from the metadata server,
// depending on the App Engine environment. See below for environment-specific
// details. If you are implementing a 3-legged OAuth 2.0 flow on App Engine that
// involves user accounts, see oauth2.Config instead.
//
// First generation App Engine runtimes (<= Go 1.9):
// AppEngineTokenSource returns a token source that fetches tokens issued to the
// current App Engine application's service account. The provided context must have
// come from appengine.NewContext.
//
// Second generation App Engine runtimes (>= Go 1.11) and App Engine flexible:
// AppEngineTokenSource is DEPRECATED on second generation runtimes and on the
// flexible environment. It delegates to ComputeTokenSource, and the provided
// context and scopes are not used. Please use DefaultTokenSource (or ComputeTokenSource,
// which DefaultTokenSource will use in this case) instead.
func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
// See comment on AppEngineTokenSource in appengine.go.
func getAppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource {
scopes := append([]string{}, scope...)
sort.Strings(scopes)
return &appEngineTokenSource{