Skip to content Skip to sidebar Skip to footer

Spreadsheet Not Found Error - Trying To Access Google Sheets

I am testing this code. import gspread from oauth2client.service_account import ServiceAccountCredentials # use creds to create a client to interact with the Google Drive API sco

Solution 1:

Ok, I finally figured it out. Face plant here...

In the file named 'statup_funding.json', you have to grab the email that is generated, then click the 'Share' button on the Spreadsheet, and paste THAT EMAIL ADDRESS into the window that opens. Then, everything works as expected. Here is a final version of my now-working code.

import gspread
#Service client credential from oauth2clientfrom oauth2client.service_account import ServiceAccountCredentials
# Print nicelyimport pprint
#Create scope
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
#create some credential using that scope and content of startup_funding.json
creds = ServiceAccountCredentials.from_json_keyfile_name('startup_funding.json',scope)
#create gspread authorize using that credential
client = gspread.authorize(creds)
#Now will can access our google sheets we call client.open on StartupName
sheet = client.open('Test_Sheet').sheet1
pp = pprint.PrettyPrinter()
results = sheet.get_all_records()
results

Post a Comment for "Spreadsheet Not Found Error - Trying To Access Google Sheets"