使用服务帐户驱动API访问文档 [英] Drive API access to document with service account

查看:87
本文介绍了使用服务帐户驱动API访问文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过服务帐户使用Google Drive Java API访问位于google.com域下的电子表格。我需要导出文档中包含的几个工作表。



我已经能够创建和使用服务帐户(通过Java API使用),但不是确定如何去访问,或者如果我想要做的甚至是可行的。我看到以下页面: https://developers.google.com/drive/web/delegation,但似乎不太可能我正在使用的服务帐户将被授予访问google.com企业网域的权限。我们在Google的帐户联系人建议我们查看论坛的建议。



鉴于此,我有几个关于方法的问题:


  • 我误解了访问要求吗?更具体地说,是否有办法授予服务帐户访问特定文档的权限?

  • 此任务(工作表导出)是否更适合Spreadsheets API?该API似乎专注于在电子表格中操作,而驱动器API似乎涉及文件/文档管理。

  • 是否需要文档副本到不同的域?
  • >


我的猜测是我们需要复制文档,但我想确定,并确保我了解API并正确访问。



谢谢!

解决方案

到文件?尝试使用方法files.get https://developers.google.com/drive / v2 / reference / files / get 如果您收到200响应,然后您有权访问,请尝试使用这些链接查找参数exportlinks
,您可以将该文件导出为不同的格式。
,否则您将无法做到这一点。




  • 只有已被授权访问文件的用户,可以访问它。如果域管理员批准的服务帐户已获批准,服务帐户可以模拟该域中的人员。如果用户模仿不能访问某个文件,服务帐户也无法访问。


  • 导出文件对于驱动器更好API,正如你所提到的Spreadsheets API是管理电子表格的内容。

  • 如果你想修改信息而不修改原始文件,那么是。




希望这有助于。


I'm attempting to access a spreadsheet that's under the "google.com" domain using the Google Drive Java API through a service account. I need to export several of the worksheets contained within the document.

I've been able to create and use a service account (used via the Java API) but am not sure how to go about access, or if what I'm trying to do is even viable. I saw the following page: https://developers.google.com/drive/web/delegation but it seems highly unlikely that a service account I'm working with will be granted access to the google.com corporate domain. Our account contact at Google suggested we check the forums for some advice.

Given this, I have a couple of questions about approach:

  • Am I misunderstanding the access requirements? More specifically is there a way to grant a service account access to a specific document?
  • Is this task (worksheet export) better suited to the Spreadsheets API? That API seemed focused on operating within a spreadsheet, and the drive API seems to deal with file/document management.
  • Will a copy of the document to a different domain be required?

My guess is that we will need to copy the document, but I wanted to be sure, and to make sure that I'm understanding the APIs and access correctly.

Thanks!

解决方案

Do you have access to the file? try to use the method files.get https://developers.google.com/drive/v2/reference/files/get if you receive a 200 response then you have access, try to find the parameter exportlinks with those links you can export the file to different formats. otherwise you won't be able to do it.

  • Only people that have been granted access to the file, can access it. in the case of service account with delegation approved by the domain admin, the service account can impersonate people in that domain. if the user it is impersonating does not have access to a certain file, the service account wont have access either.

  • To export the file is better with the Drive API, as you mentioned the Spreadsheets API is to manage the content of the spreadsheet.

  • If you want to modify the information without modifying the original file, then yes.

hope this helps.

这篇关于使用服务帐户驱动API访问文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆