如何使用服务帐户凭据访问Google Spreadsheets? [英] How to access Google Spreadsheets with a service account credentials?

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

问题描述

我已经用PHP创建了一个服务器端应用程序,该应用程序应该可以与Google Spreadsheets一起使用.

I have created a server side application in PHP that's supposed to work with Google Spreadsheets.

我能够通过OAuth 2.0身份验证成功进行身份验证,但是当从Google请求电子表格列表时,我只会让电子表格所有者将电子表格与服务帐户共享.

I'm able to authenticate successfully with OAuth 2.0 authentication, but when requesting the list of the spreadsheets from Google, I only get the spreadsheets shared with the service account by the spreadsheet owner.

服务帐户是否有办法检索我的主帐户而非服务帐户所拥有的所有电子表格,包括未与服务帐户明确共享的那些电子表格?

Is there a way that service account could retrieve all the spreadsheets owned by my main account not the service one, including those not explicitly shared with the service account?

我仍然想保持电子表格的私密性,以便没有我的允许没有人可以访问它们,但是我需要服务帐户才能完全访问现有和新的电子表格.

Also I still want to keep the spreadsheets private so noone can access them without my permission, but I need the service account to have full access to both existing and new spreadsheets.

任何建议都值得赞赏.

推荐答案

您必须更改方法:

  1. 在云端硬盘中创建服务帐户.您只能通过API(而不是通常的Web界面)来管理和使用此帐户.

  1. Create a service account in Drive. You can manage and use this account only with the API (not with the web interface as usually)

使用Drive API,您可以列出,创建,更新,删除和更改文件的权限.创建新文件时,您可以始终通过API将其共享给所需的用户,公开该新文件或更改所有权.

With the Drive API you can list, create, update, delete and change the permissions of the files. When you create a new file, you can share it - always with API - to the users you want, make the new file public or change the ownership.

请查看: https://developers.google.com/drive/v2/reference/permissions

这篇关于如何使用服务帐户凭据访问Google Spreadsheets?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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