I have a simple script with creating googlesheet on Python 3.6 like:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
mail = '[email protected]'
secret_file = "C:\\Users\\admin\\Downloads\\my_file.json"
SCOPES = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(secret_file, SCOPES)
gss_client = gspread.authorize(credentials)
gss = gss_client.open('test-doc')
worksheet = gss.sheet1
But when I run it, I have a type-error:
Traceback (most recent call last): File "C:/Users/admin/PycharmProjects/untitled/fjhdshfjs.py", line 11, in ... "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\base64.py", line 58, in b64encode encoded = binascii.b2a_base64(s, newline=False) TypeError: a bytes-like object is required, not 'str'
Early, this trouble could be resolved with encoding:
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
But now, it doesn`t work after moving SignedJwtAssertionCredentials onto oauth2client.service_account.ServiceAccountCredentials
Maybe somebody can help me?
gspread.authorize("credentials.json")
– fcsr