From fd973c789cc6b9de1d8dbdbf07e0fb42a2dac38e Mon Sep 17 00:00:00 2001 From: Sheeri Date: Mon, 3 Aug 2015 09:36:38 -0400 Subject: [PATCH] updated to use oauth2 Updated to use oauth2 (separate oauth2_credentials.json not supplied, will be different and private for each user) instead of username/password, which was decom'd in April 2015. Also updated to get output path and document list from config.py. --- download-spreadsheet.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/download-spreadsheet.py b/download-spreadsheet.py index 5060f5d..2bff289 100644 --- a/download-spreadsheet.py +++ b/download-spreadsheet.py @@ -3,19 +3,20 @@ import urllib import codecs from config import config - +import json +from oauth2client.client import SignedJwtAssertionCredentials #config -username = config['USERNAME'] -password = config['PASSWORD'] -docs = [ - {"doc": "My 1st Spreadsheet Name"}, - {"doc":"My 2nd Spreadsheet Name"} - ] +docs = config['DOCS'] +# open the json file with the oath2 credentials +json_key = json.load(open('oauth2_credentials.json')) +scope = ['https://spreadsheets.google.com/feeds'] # login first -client = gspread.login(username, password) +credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) + +client = gspread.authorize(credentials) #process doc list for doc in docs: