Welcome to gspread adventures: setup:**
- in some setup directory git clone https://github.com/burnash/gspread.git
- install: sudo python setup.py install
- install oath2client: sudo pip install –upgrade oauth2client
- generate/get json credentials
- add in .bashrc: export GOOGLE_APPLICATION_CREDENTIALS=“/path/to.json”
You will get a “spreadsheet not found” error unless you share the sheet with the client email from your credentials. Just look at the json file and find the client email. Then share the sheet with that email.
Creating the credentials:
- I created an app engine, having no idea which engine to pick. There's a compute engine. No answers found quickly on Google regarding the difference.
One option for credentials with gspread:
from oauth2client.client import GoogleCredentials credentials = GoogleCredentials.get_application_default() credentials = credentials.create_scoped(['https://spreadsheets.google.com/feeds'])
gs = gspread.authorize(credentials)
sheet = gs.open('file').worksheet('sheet')
Here's the way suggested by Google (untested with sharing client email):
import gspread from oauth2client.service_account
import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
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
Using the latest Gspread (0.6.2) on 14.04
Update requests:
apt-add-repository "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main" apt-get update apt-get install python-requests # it installs 2.10.0 apt-add-repository -r "deb http://us.archive.ubuntu.com/ubuntu/ yakkety main" apt-get update