无法看到带有服务帐户的gSuite文件
问题:我已创建服务帐户以与我的组织的Google Drive &电子表格文件进行交互 - 我可以成功创建会话以访问Google Drive API。但是,我有机会获得唯一的文件是这样的样板:无法看到带有服务帐户的gSuite文件
=> [#< Google云端硬盘::文件ID = “aSdsefooovjTnulaRlclbarrr” 称号= “入门”>]
什么水平你认为我失踪的权限?
我唯一能想到的就是,其他一些*权限隐藏来自org外部的文件。即使服务帐号是明确地在文件上共享的吗?如果有任何指示,我会与服务帐户分享。
也许与此文档中的下列图像有关?
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority
步骤,我已经经历了..
1)我创建了域范围代表团和项目编辑状态的服务帐户。
2)我邀请的服务帐户电子邮件至我希望它有
3)我有我的组织的gSuite管理员已经添加了该服务帐户的CLIENT_ID到/安全API访问张/管理API客户端访问..与范围 - >https://www.googleapis.com/auth/drive,https://spreadsheets.google.com/feeds
想尽组合,我可以在所有的文档/教程找到。这是我的连接代码,基于https://www.twilio.com/blog/2017/03/google-spreadsheets-ruby.html。尝试在client_secret.json中传递范围。为服务帐户尝试使用iam角色的工具。
session = GoogleDrive::Session.from_service_account_key("client_secret.json")
{
"type": "service_account",
"project_id": "gdrive-1231233",
"private_key_id": "food87c0bar16da9bfoooooo677bar",
"private_key": "-----BEGIN PRIVATE KEY-----\nsssEIEvQfooobarrrytyeho=\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "foo40990211bar",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_foox_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_foox_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/servicebot%40gdrive-foobar.iam.gserviceaccount.com"
}
#<GoogleDrive::Session:0v3fc6c3e25061>
所以原来我可以用它来找到一个明确的电子表格是spreadsheet_by_url的唯一方法 - .files .spreadsheets .find_by_guid,等等。所有返回nil。但通过url搜索直接返回的文件,并启用我的读/写。
session = GoogleDrive::Session.from_service_account_key("client_secret.json")
session.spreadsheet_by_url(ENV['GOOGLE_DATA_DUMP_URL'])
worksheet = spreadsheet.worksheets[0]