Skip to content

Instantly share code, notes, and snippets.

@egradman
Last active November 2, 2022 04:59
Show Gist options
  • Save egradman/3b8140930aef97f9b0e4 to your computer and use it in GitHub Desktop.
Save egradman/3b8140930aef97f9b0e4 to your computer and use it in GitHub Desktop.
Simple Google Spreadsheets to Pandas DataFrame in IPython Notebook
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kervel
Copy link

kervel commented Sep 14, 2016

btw, if you are (like us) on python3 with a buggy httplib2 that refuses to connect to a proxy server, the hack below makes oauthlib2 use requests instead of httplib2

class DropInHttplib():
    def __init__(self):
        self.sess = requests.session()

    def request(self, uri, method='GET' , body=None , headers=None):
        resp = None
        if method.lower() == 'get':
            resp = self.sess.get(uri, headers=headers)

        elif method.lower() == 'post':
            resp = self.sess.post(uri,data=body,headers=headers)
        if resp.status_code == 200:
            resp.status = httplib2.http.client.OK
        else:
            resp.status = httplib2.http.client.BAD_REQUEST
        return (resp,resp.text)

then, one can do

httpclient = DropInHttplib()
credentials = oauth2client.tools.run_flow(flow, storage, flags, httpclient)

and we needed to modify the flags so that it would work on a server (where we could not open a browser window)

flags = argparse.ArgumentParser(parents=[oauth2client.tools.argparser]).parse_args(["--noauth_local_webserver"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment