获取用户的Google表格访问权限使用OAUTH。

huangapple go评论65阅读模式
英文:

Getting access to the user's google sheet with OAUTH

问题

我希望你了解diagrams.net。这个网站允许用户使用他/她的Gmail登录,并请求访问用户的Google Drive的权限。之后,它可以自由地对Google Drive进行CRUD操作。

我想实现同样的功能,但只针对Google表格,而不是整个Google Drive。

如何实现这个功能?

英文:

I hope you know about diagrams.net. This website allows the user to login with his/her gmail, and it asks for permission to access of the user's google drive. After that it can freely do CRUD on the google-drive

I want the same but with only google sheets not the whole google-drive

How to implement this feature?

答案1

得分: 3

抱歉,以下是翻译好的部分:

如果您想要访问用户的 Google 表格,那么您需要访问他们的 Drive 帐户。没有办法仅访问表格,要么全部访问。

如果您只想读取单个表格,仍然需要只读的 Drive 范围:

https://www.googleapis.com/auth/drive.readonly

这将使您能够“查看和下载所有您的 Google Drive 文件”。

如果您想使用 Google Sheets API 写入文件,那么您将需要:

https://www.googleapis.com/auth/drive

这将使您能够“查看、编辑、创建和删除您的 Google Drive 文件”。

再次强调,这是全盘接管,无法限制到单个文件或文件类型。

英文:

Unfortunately its not that simple.

If you want access to a users google sheet. Then you need access to their drive account. There is now way to get access to only the sheets. Its all or nothing.

If you just want to read a single sheet you still need the read only drive scope

https://www.googleapis.com/auth/drive.readonly

Which gives you access to See and download all your Google Drive files

If you want to write to the file using the google sheets api. then you are going to need

https://www.googleapis.com/auth/drive	

Which gives you access See, edit, create, and delete all of your Google Drive files

again this is all or nothing. There is no way to limit it to a single file or file mimetype.

huangapple
  • 本文由 发表于 2023年6月29日 16:42:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579435.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定