burnash/gspread — pull request #86 by martinhbramwell (2013-11-21 18:28:46+00:00)
Title: Adds an "authorize()" method for OAuth as alternative to "login()"

Hi again Anton,

In my second attempt here, I have shaved the code down to the bare minimum necessary to handle usage, *and refreshing*, of OAuth authorization credentials.

Apart from the altered code you see below I have also created [a new *gist*](https://gist.github.com/martinhbramwell/7553524) demo script and [a new wiki page](https://github.com/FleetingClouds/gspread/wiki/How-to-get,-use-and-refresh-OAuth-access-tokens-for-gspread.) both elaborating on the ones you did.

In the gist, you will see that I replaced the deprecated _run()_ procedure call with the more recent one _run-flow()_. I also prompt the user to enter required data, rather than have them edit the file. I generate a complete set of Python variables to be used in any program that needs to use gspread with OAuth.

I copied and enhanced your wiki page. My changes add two new sections. The [first addition](https://github.com/FleetingClouds/gspread/wiki/How-to-get,-use-and-refresh-OAuth-access-tokens-for-gspread.#wiki-authenticationNew) explains how to get authentication credentials from Google's recently published new API Console. The [second addition](https://github.com/FleetingClouds/gspread/wiki/How-to-get,-use-and-refresh-OAuth-access-tokens-for-gspread.#wiki-authorizationRefresh) explains how to set up and test my alternative "authorize()" method in a *virtualenv* environment, so as not to risk reconfiguring the user's system inappropriately.

Before committing, I pulled your latest changes so that you can merge this request automatically.

Sincere regards,
MHJB