如何上传到我的Google云端硬盘帐户,而不是用户 [英] How upload to MY Google Drive account, not the users

查看:229
本文介绍了如何上传到我的Google云端硬盘帐户,而不是用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:



有人来到我的网站,他们看到一个文件选择字段。他们选择文件并将文件上传到我的Google云端硬盘帐户。



问题:

在查看Google Drive SDK文档时,我看到它使用OAuth进行身份验证,但我不需要对用户进行身份验证,因为他们正在上传到我的Google云端硬盘帐户。我知道我需要向Google注册我的应用程序,但我想知道是否可以上传,而无需授权用户使用OAuth的典型方式(发送离线或模式窗口以验证w /重定向URL)。

这可能吗?

解决方案

您有两个选择: - $ /


  1. 使用服务帐户。这些文件将被上传到服务帐户


  2. 使用普通的Google帐户。对于此选项,您(作为帐户所有者)需要执行一次性身份验证才能获取您将存储的刷新令牌。然后,您可以随时使用它来生成调用实际Drive API所需的访问令牌。您可以使用Oauth Playground生成刷新标记,因此不需要编写任何代码。

  3. =https://stackoverflow.com/questions/19766912/how-do-i-authorise-a-background-web-app-without-user-intervention-canonical>如何授权应用程序(网页或安装)没有用户干预? (规范?)


    Scenario:

    Someone comes to my website and they see a file select field. They select the file and upload the file to MY Google Drive account.

    Problem:

    In looking at the Google Drive SDK docs I see that it uses OAuth for authentication, but I don't need to authenticate the user because they are uploading to MY Google Drive account. I'm aware that I need to register my application with Google, etc. but I'd like to know if I can upload without authorizing the user with OAuth the typical way (sending offsite or modal window to validate w/ redirect URL).

    Is this possible to do? I'm using PHP.

    解决方案

    You have two options:-

    1. Use a Service Account. The files will be uploaded to the account of the Service Account

    2. Use a regular Google account. For this option, you (as the account owner) will need to do a one-off auth to get a refresh token, which you will store. You can then use this any time to generate the access token needed to invoke the actual Drive API. You can generate the refresh token using the Oauth Playground, so no need to write any code.

    See How do I authorise an app (web or installed) without user intervention? (canonical ?)

    这篇关于如何上传到我的Google云端硬盘帐户,而不是用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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