通过api访问谷歌驱动器文件没有登录? [英] Access google drive files via api without logging in?

查看:186
本文介绍了通过api访问谷歌驱动器文件没有登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个网页,可以在我的谷歌驱动器上显示有关文档的信息。例如,我想在网页上显示我所有的Google文档的标题。我不希望用户必须登录到Google帐户,并且我不希望授权任何内容(或者用户授权任何内容)。我只希望用户能够看到我显示的内容 - 以只读格式 - 当他们导航到页面时。用户将没有机会编辑或上传或删除任何东西,他们只能查看我显示的信息。



有没有办法从谷歌驱动器获取文件(通过API或任何其他方式)可能不使用oauth 2.0?我浏览了api文档,甚至编写了示例应用程序,但是他们都有一个步骤说:转到此URL,单击允许,输入代码,然后获得访问权限。这些步骤不应该是必需的。我只是想下载文件,并能够操纵它(无论是在内存中或作为一个流),然后显示一些有关它。



另外,我可能会误解OAuth 2.0的作品,所以如果看起来如此,任何有用的信息将不胜感激。感谢您。

解决方案

您无需认证您的访问者进入Google,但需要对自己进行身份验证,以便您的网络应用可以从您的个人Drive中检索数据。

为自己获取访问令牌和刷新令牌,存储它们并对请求进行验证。如果您正在使用我们的客户端库中的一个,则其中大多数客户端库一旦过期就刷新访问令牌。请参阅使用OAuth 2.0进行Web服务器应用程序以获取更多详细信息和 OAuth 2.0 Playground 可帮助您了解如何获取这些令牌。


I am trying to make a webpage that can display information about documents on my google drive. For example I would like to display the titles of all my google documents on a webpage. I don't want the user to have to be logged into a google account, and I don't want to have to authorize anything (or the user to authorize anything). I just want the user to be able to see what I display - in a read only format - when they navigate to the page. The user will have no chance to edit or upload or delete anything, they can just view the info I display.

Is there a way to get files from google drive (via the API or any other way) possibly without using oauth 2.0? I've looked through the api docs and even coded up the sample apps, but all of them have a step that says, "Go to this URL, click Allow, enter the code" then you get access. These steps shouldn't be necessary. I just want to download the file and be able to manipulate it (either in memory or as a stream) then display something about it.

Also, I may misunderstand how OAuth 2.0 works so if that seems like the case, any helpful information would be much appreciated. Thank you.

解决方案

You don't need to authenticate your visitors into Google, but need to authenticate yourself, so your web app can retrieve data from your personal Drive.

Get an access token and refresh token for yourself, store them and autenticate your requests. If you're using one of our client libraries, most of them refresh the access tokens once they are expired. See Using OAuth 2.0 for Web Server Applications for more details and OAuth 2.0 Playground helps you to understand how to get these tokens.

这篇关于通过api访问谷歌驱动器文件没有登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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