Skip to content

Commit 541b743

Browse files
committed
Fix deprecated SignedJwtAssertionCredentials
1 parent 8383571 commit 541b743

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

examples/google_spreadsheet.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
import Adafruit_DHT
4242
import gspread
43-
from oauth2client.client import SignedJwtAssertionCredentials
43+
from oauth2client.service_account import ServiceAccountCredentials
4444

4545
# Type of sensor, can be Adafruit_DHT.DHT11, Adafruit_DHT.DHT22, or Adafruit_DHT.AM2302.
4646
DHT_TYPE = Adafruit_DHT.DHT22
@@ -81,10 +81,8 @@
8181
def login_open_sheet(oauth_key_file, spreadsheet):
8282
"""Connect to Google Docs spreadsheet and return the first worksheet."""
8383
try:
84-
json_key = json.load(open(oauth_key_file))
85-
credentials = SignedJwtAssertionCredentials(json_key['client_email'],
86-
json_key['private_key'],
87-
['https://spreadsheets.google.com/feeds'])
84+
scope = ['https://spreadsheets.google.com/feeds']
85+
credentials = ServiceAccountCredentials.from_json_keyfile_name(oauth_key_file, scope)
8886
gc = gspread.authorize(credentials)
8987
worksheet = gc.open(spreadsheet).sheet1
9088
return worksheet

0 commit comments

Comments
 (0)