Oauth 2.0 使用gspread API和oauth2时,权限错误
使用此代码:Oauth 2.0 使用gspread API和oauth2时,权限错误,oauth-2.0,permissions,credentials,gspread,Oauth 2.0,Permissions,Credentials,Gspread,使用此代码: import gspread from oauth2client.service_account import ServiceAccountCredentials scope = ['https://www.googleapis.com/auth/spreadsheets', 'https://spreadsheets.google.com/feeds'] credentials = ServiceAccountCredentials.from_json_keyf
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://www.googleapis.com/auth/spreadsheets',
'https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('Consumer
Outr.json', scope)
gc = gspread.authorize(credentials)
nonStartFreeTrial = gc.open("Consumer Outreach")[0]
我需要使用google提供的服务凭据API,而不是常规API密钥,我不断得到:
APIError: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
我正在用ipynb编写这段代码,理想情况下,我将能够从活动单元格访问电子表格。我已经读到,可以使用API密钥修复此问题,但gspread文档建议使用服务帐户凭据是最好的方法。真的不知道该修复什么(谷歌API的新功能!) 请检查这个答案@Burnash非常感谢!真的帮了大忙。