【发布时间】:2021-12-10 09:51:50
【问题描述】:
请帮帮我。启动从 google sheet 输出数据的程序时,出现错误。
import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials
# Работа с таблицами
CREDENTIALS_FILE = 'file_name.json'
credentials = ServiceAccountCredentials.from_json_keyfile_name(CREDENTIALS_FILE, ['https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/drive'])
httpAuth = credentials.authorize(httplib2.Http())
service = apiclient.discovery.build('sheets', 'v4', http = httpAuth) # Выбираем работу с таблицами и 4 версию API
spreadsheetId = '1oXzqYQ9HixjfkTJ7hmIVqrM7_uvYwPsHoEKqPdbaAgk'
driveService = apiclient.discovery.build('drive', 'v3', http = httpAuth)
access = driveService.permissions().create(
fileId = spreadsheetId,
body = {'type': 'user', 'role': 'writer', 'emailAddress': 'account@requests-329915.iam.gserviceaccount.com'},
fields = 'id'
).execute()
错误:
googleapiclient.errors.HttpError:
【问题讨论】:
标签: python google-sheets oauth-2.0 http-status-code-403