From 8e000ed3900649a51207a3b6d6e4d99e2ae9aeee Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Tue, 7 Feb 2012 15:41:44 -0500 Subject: [PATCH] Allow an http object to be passed into tools.run() so that proxy settings will be used. Reviewed in http://codereview.appspot.com/5646045/. Fixes issue #91. --- oauth2client/tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oauth2client/tools.py b/oauth2client/tools.py index d441cd9..236c859 100644 --- a/oauth2client/tools.py +++ b/oauth2client/tools.py @@ -90,12 +90,14 @@ class ClientRedirectHandler(BaseHTTPServer.BaseHTTPRequestHandler): pass -def run(flow, storage): +def run(flow, storage, http=None): """Core code for a command-line application. Args: flow: Flow, an OAuth 2.0 Flow to step through. storage: Storage, a Storage to store the credential in. + http: An instance of httplib2.Http.request + or something that acts like it. Returns: Credentials, the obtained credential. @@ -152,7 +154,7 @@ def run(flow, storage): code = raw_input('Enter verification code: ').strip() try: - credential = flow.step2_exchange(code) + credential = flow.step2_exchange(code, http) except FlowExchangeError, e: sys.exit('Authentication has failed: %s' % e)