Reputation: 69
Error:
Traceback (most recent call last):
File
"C:\Users\skansal\Desktop\Agile_Tool\Agile_Google_Sheets\Google_Api.py",
line 10, in
gs = gspread.authorize(credentials)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\gspread_init_.py", line 38, in authorize
client.login()
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\gspread\client.py", line 51, in login
self.auth.refresh(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 545, in refresh
self._refresh(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 749, in _refresh
self._do_refresh_request(http)
File "C:\Users\skansal\AppData\Local\Programs\Python\Python36\lib\site-
packages\oauth2client\client.py", line 819, in _do_refresh_request
raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_scope:
http://www.googleapis.com/auth/drive is not a valid audience string.
I made sure all the following things are enabled.
My Code:
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import gspread
scope = ['http://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('credential_token.json',scope)
gs = gspread.authorize(credentials)
worksheet = gc.open('Project_Sheet').sheet1
print(wks.get_all_records())
I want to be able to connect to the google sheet through python so that i would be able to perform the read,write and update operations on the sheet. I am new to python. Sorry in advance if i made a mistake while posting the question
Upvotes: 0
Views: 427
Reputation: 22306
The answer is in the question
invalid_scope:
http://www.googleapis.com/auth/drive is not a valid audience string.
It should be https://www.googleapis.com/auth/drive
Upvotes: 2