oauth2/google
Michael Traver be148ec7a7 Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes
Go 1.11 on App Engine standard is a "second generation" runtime, and
second generation runtimes do not set the appengine build tag.
appengine_hook.go was behind the appengine build tag, meaning that
AppEngineTokenSource panicked on the go111 runtime, saying,
"AppEngineTokenSource can only be used on App Engine."

The second gen runtimes should use ComputeTokenSource, which is also
what flex does [1]. This commit does two things to remedy the situation:

1. Put the pre-existing implementation of AppEngineTokenSource behind
   the appengine build tag since it only works on first gen App Engine
   runtimes. This leaves first gen behavior unchanged.
2. Add a new implementation of AppEngineTokenSource and tag it
   !appengine. This implementation will therefore be used by second gen
   App Engine standard runtimes and App Engine flexible. It delegates
   to ComputeTokenSource.

The new AppEngineTokenSource implementation emits a log message
informing the user that AppEngineTokenSource is deprecated for second
gen runtimes and flex, instructing them to use DefaultTokenSource or
ComputeTokenSource instead. The documentation is updated to say the
same.

In this way users will not break when upgrading from Go 1.9 to Go 1.11
on App Engine but they will be nudged toward the world where App Engine
runtimes have less special behavior.

findDefaultCredentials still calls AppEngineTokenSource for first gen
runtimes and ComputeTokenSource for flex.

Fixes #334

Test: I deployed an app that uses AppEngineTokenSource to Go 1.9 and
      Go 1.11 on App Engine standard and to Go 1.11 on App Engine
      flexible and it worked in all cases. Also verified that the log
      message is present on go111 and flex.

[1] DefaultTokenSource did use ComputeTokenSource for flex but
AppEngineTokenSource did not. AppEngineTokenSource is supported on flex,
in the sense that it doesn't panic when used on flex in the way it does
when used outside App Engine. However, AppEngineTokenSource makes an API
call internally that isn't supported by default on flex, which emits a
log instructing the user to enable the compat runtime. The compat
runtimes are deprecated and deploys are blocked. This is a bad
experience. This commit has the side effect of fixing this.
2018-10-30 17:40:45 -07:00
..
testdata/gcloud oauth2/google: fix decode error in Cloud SDK config 2015-02-12 05:35:05 +00:00
appengine.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
appengine_gen1.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
appengine_gen2_flex.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
default.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
doc_go19.go google: add CredentialsFromJSON 2018-03-12 23:58:49 +00:00
doc_not_go19.go google: add CredentialsFromJSON 2018-03-12 23:58:49 +00:00
example_test.go google: add CredentialsFromJSON 2018-03-12 23:58:49 +00:00
go19.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
google.go google: add CredentialsFromJSON 2018-03-12 23:58:49 +00:00
google_test.go google: make JWTConfigFromJSON set TokenURL from the JSON's token_uri 2016-09-02 05:03:02 +00:00
jwt.go google: support key ID in JWTAccessTokenSourceFromJSON 2016-07-02 01:08:09 +00:00
jwt_test.go google: fix warnings from go vet 2016-07-19 16:36:24 +00:00
not_go19.go Add a new AppEngineTokenSource impl for 2nd gen App Engine runtimes 2018-10-30 17:40:45 -07:00
sdk.go internal: move ParseINI into google 2018-01-02 15:01:02 +00:00
sdk_test.go internal: move ParseINI into google 2018-01-02 15:01:02 +00:00