oauth
oauth copied to clipboard
app engine support
App Engine requires use of context-specific HTTP clients. Outbound HTTP requests simply don't work unless there's a way to provide the current request context to the outgoing request.
Because a *Consumer might outlast multiple requests, we need a way to thread the request context through and then optionally create an *http.Client based on it. Unfortunately, this requires adding a bunch of new arguments.
My preference would be to require contexts for all callsites, but I realize that breaks backwards compatibility, so I've added new methods.
Hi, thanks for the patch. I'm really sorry it took me so long to get to it!
Admittedly, it's been quite some time since I've used AppEngine on a regular basis, so things could have changed. However, in the past it was possible to use this library inside of AppEngine by supplying your own HttpClient constructed using an AppEngine context.
Unfortunately, my original use case got migrated to OAuth 2.0, so I can't verify that it still works. However, I think this code is almost identical to the technique I used:
https://github.com/unrealities/warning-track/blob/cdfc6a1037339e27721f1171390ace4616a31b22/services/twitter.go
Eliding a few details it looks like:
// r is a *http.Request c := appengine.NewContext(r) client := urlfetch.Client(c) consumer = oauth.NewCustomHttpClientConsumer( tc.ConsumerKey, tc.ConsumerSecret, oauth.ServiceProvider{ RequestTokenUrl: = [...] }, client);
Will this existing interface meet your needs?