I have a python script successfully updating google sheets through Raspberry pi using oauth2client
and gspread
. When I try and run the same script off my desktop Ubuntu it throws an error 403 Insufficient Permissions
. I'm running them both in IDLE2
if that matters.
I am a novice, but I have imported gspread
& oauth2client
libraries, and some things called pypy
, openSSL
& pycrypto
. I have copied the whole folder from the Raspberry pi and am running it out of that folder so it contains the same json
Key document.
I'm probably missing something obvious. If you can answer, please dumb it down for a relative newbie. Thanks.
Update 9:20PM March 13: I downloaded new credentials from google directly to Ubuntu, updated the code and tried again but received the same error.
Here's the error:
`Traceback (most recent call last):
File "/home/heather/Desktop/Heather/DEV/18-03-11-Category-Log.py", line 15, in <module>
wks = gc.open("meditation_logger").sheet1
File "/home/heather/.local/lib/python2.7/site-packages/gspread/v4/client.py", line 103, in open
self.list_spreadsheet_files()
File "/home/heather/.local/lib/python2.7/site-packages/gspread/v4/client.py", line 80, in list_spreadsheet_files
r = self.request('get', url)
File "/home/heather/.local/lib/python2.7/site-packages/gspread/v4/client.py", line 73, in request
raise APIError(response)
APIError: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}`
Here's the code (I've used #### to cover my key file name):
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from datetime import datetime
import serial
from time import localtime, strftime
#import time
import serial
#rpi serial port with arduino
ser = serial.Serial('/dev/ttyACM0',115200)
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('################.json', scope)
gc = gspread.authorize(credentials)
#sh = gc.create('meditation_logger1')
wks = gc.open("meditation_logger").sheet1
wks.resize(1)
#wks.update_acell('B2', 'crud')
def ok_to_begin():
print "ok to begin"
ok_to_begin()
while True:
wks = gc.open("meditation_logger").sheet1
data = ser.readline().strip()
(... etc. I think the rest of the code isn't really relevant.. just logging instructions for different serial data)