0

I am trying to use gpread with python to edit google spreadsheets. I followed this tutorial: http://gspread.readthedocs.org/en/latest/oauth2.html When I run my code, it says that there is no module named oauth2client.client. Do I need to install something else to make it work?

Update here is my code:

import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials

json_key = json.load(open('GraduationCash-c4b4c0667c75.json'))
scope = ['https://spreadsheets.google.com/feeds']

credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
gc = gspread.authorize(credentials)

wks = gc.open("Where is the money Lebowski?").sheet1

raw_input()

Also i should mention that I am on windows 8, so those commands are not working. it is still saying that there is no crypto library avalible

Amir
  • 10,600
  • 9
  • 48
  • 75
UltraSaucy
  • 11
  • 1
  • 2
  • Welcome to [Stack Overflow](https://stackoverflow.com)! This is not nearly enough information for us to help you. Can you update the question with your code (or better yet, a [minimal working example](https://en.wikipedia.org/wiki/Minimal_Working_Example)) and the exact error message? – Mike Ounsworth May 09 '15 at 14:54

2 Answers2

2

Yes, you must install OAuth client library:

$ pip install --upgrade oauth2client

Of course, you always can install from source, also well:

$ git clone https://github.com/google/oauth2client 
$ cd oauth2client 
$ python setup.py install

Note After intall if you get a error like "No crypto library available":

$ apt-get install python-openssl 

or

$ pip install PyOpenSSL
felipsmartins
  • 13,269
  • 4
  • 48
  • 56
  • ok, I installed the oauth library, but now I am getting another error. It says that there is no crypto library available. – UltraSaucy May 10 '15 at 01:54
2

Instead of using SignedJwtAssertionCredentials, I've used GoogleCredentials.

I had success with the following code below. I had to create an account on the Google Developer site here. From there, go to API Manager > Google Apps API > Drive API, then Enable API. Then select Credentials > New Credentials > Service account key. At this point, download the key as JSON and store it somewhere secure. Copy the email address in the JSON file and add it to the sheet you want to access.

import 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('Testing').worksheet('Sheet1')

list_of_lists = sheet.get_all_values()

print(list_of_lists)
Chase Wright
  • 369
  • 3
  • 3