Support for Google AppEngine urlfetch for OAuth2 #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To use http in Google AppEngine, you have to use urlfetch, not
the normal default http client or RoundTripper. So similar to
what one of the forks of goauth2 did, this adds the ability via
the now-added common/SetRoundTripper to pass in the specific
RoundTripper to use. If unset, the default net/http one will be
used. However, by calling this method, you can pass in your own
including one created via urlfetch. Here is sample code showing
it in use:
import (
"appengine"
"github.com/stretchr/gomniauth/common"
)
func SomeGolangFunc([...,] r *http.Request [,...]) {
c := appengine.NewContext(r)
t := new(urlfetch.Transport)
t.Context = c
common.SetRoundTripper(t)
// Do something interesting here
}
Note that common.SetRoundTripper may have to be called in the GAE
server before every request, versus trying to do it once because
of the appengine.Context being passed in. Pretty sure you cannot
pass in a nil *http.Request and re-use the context, so you can't
make the call during the GAE init() method.