From 94b24919e8c14921f65992df8f5a42611077d576 Mon Sep 17 00:00:00 2001 From: JMensch Date: Tue, 23 Feb 2016 12:05:14 -0500 Subject: [PATCH 1/4] oauth2 documentation update FIX: OAuth2.rst now properly describes how to get set up with oauth2client v2.0.0 --- docs/oauth2.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/oauth2.rst b/docs/oauth2.rst index 386cfdd82..0e5cb024f 100644 --- a/docs/oauth2.rst +++ b/docs/oauth2.rst @@ -65,12 +65,11 @@ Depending on your system setup you may need to install PyOpenSSL: import json import gspread - from oauth2client.client import SignedJwtAssertionCredentials + from oauth2client.service_account import ServiceAccountCredentials - json_key = json.load(open('gspread-april-2cd … ba4.json')) scope = ['https://spreadsheets.google.com/feeds'] - credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) + credentialss = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope) gc = gspread.authorize(credentials) From 913544ce179e751d8ec4d2d0b617ad6afe0238f4 Mon Sep 17 00:00:00 2001 From: JMensch Date: Sun, 28 Feb 2016 18:13:03 -0500 Subject: [PATCH 2/4] correct typo --- docs/oauth2.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/oauth2.rst b/docs/oauth2.rst index 0e5cb024f..1d1a0e821 100644 --- a/docs/oauth2.rst +++ b/docs/oauth2.rst @@ -69,7 +69,7 @@ Depending on your system setup you may need to install PyOpenSSL: scope = ['https://spreadsheets.google.com/feeds'] - credentialss = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope) + credentials = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope) gc = gspread.authorize(credentials) From f545dbca8b460de34718f4d772001280f37034d6 Mon Sep 17 00:00:00 2001 From: JMensch Date: Sun, 28 Feb 2016 18:17:17 -0500 Subject: [PATCH 3/4] add section for oauth2client < 2.0.0 setup --- docs/oauth2.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/oauth2.rst b/docs/oauth2.rst index 1d1a0e821..da537cf0c 100644 --- a/docs/oauth2.rst +++ b/docs/oauth2.rst @@ -61,9 +61,27 @@ Depending on your system setup you may need to install PyOpenSSL: 6. Now you can read this file, and use the data when constructing your credentials: +If using oauth2client < 2.0.0 + :: import json + import gspread + from oauth2client.client import SignedJwtAssertionCredentials + + json_key = json.load(open('gspread-april-2cd … ba4.json')) + scope = ['https://spreadsheets.google.com/feeds'] + + credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) + + gc = gspread.authorize(credentials) + + wks = gc.open("Where is the money Lebowski?").sheet1 + +If using oauth2client >= 2.0.0 + +:: + import gspread from oauth2client.service_account import ServiceAccountCredentials From 5a04faba6d64f0197c772e02c3cc52c76fe24c34 Mon Sep 17 00:00:00 2001 From: JMensch Date: Thu, 17 Mar 2016 15:03:16 -0700 Subject: [PATCH 4/4] doc update --- docs/oauth2.rst | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/oauth2.rst b/docs/oauth2.rst index da537cf0c..ce74d50ea 100644 --- a/docs/oauth2.rst +++ b/docs/oauth2.rst @@ -61,33 +61,31 @@ Depending on your system setup you may need to install PyOpenSSL: 6. Now you can read this file, and use the data when constructing your credentials: -If using oauth2client < 2.0.0 - :: - import json import gspread - from oauth2client.client import SignedJwtAssertionCredentials + from oauth2client.service_account import ServiceAccountCredentials - json_key = json.load(open('gspread-april-2cd … ba4.json')) scope = ['https://spreadsheets.google.com/feeds'] - credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) + credentials = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope) gc = gspread.authorize(credentials) wks = gc.open("Where is the money Lebowski?").sheet1 -If using oauth2client >= 2.0.0 +If using oauth2client < 2.0.0 :: + import json import gspread - from oauth2client.service_account import ServiceAccountCredentials + from oauth2client.client import SignedJwtAssertionCredentials + json_key = json.load(open('gspread-april-2cd … ba4.json')) scope = ['https://spreadsheets.google.com/feeds'] - credentials = ServiceAccountCredentials.from_json_keyfile_name('gspread-april-2cd … ba4.json', scope) + credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) gc = gspread.authorize(credentials)