简体   繁体   English

Google Drive API访问我自己的帐户

[英]Google Drive API Access my own account

I wish to run a simple process on my server/laptop that will upload files to my google drive on a daily basis, once a day. 我希望在服务器/笔记本电脑上运行一个简单的过程,每天将文件每天上传一次到Google驱动器中。 I don't wish to share this, allow other users to use it etc. 我不想分享此信息,不允许其他用户使用它等。

All examples I find seem to involve browsing to an address to gain permission from the user (me) and then getting an auth code etc and proceding 我发现的所有示例似乎都涉及浏览到一个地址以获得用户(我)的许可,然后获取身份验证代码等并继续

ref: Java quickstart 参考: Java快速入门

  1. Is there a way/example to do this without need of a browser, getting permission getting unique auth code each time as I only want to do this for my account? 有没有一种方法/示例可以做到这一点而无需浏览器,每次我只想为自己的帐户获得许可时都获得唯一的身份验证代码?
  2. Can I use a bash script with CURL commands rather than having to use Java? 我可以将bash脚本与CURL命令一起使用,而不必使用Java吗?
  1. Yes. 是。 See How do I authorise an app (web or installed) without user intervention? 请参阅如何在没有用户干预的情况下授权应用程序(网络或已安装)? (canonical ?) (规范?)

  2. Yes. 是。 It becomes a complicated script if your file is large and you are doing resumable uploads, but for small files it's perfectly feasible. 如果您的文件很大并且正在执行可恢复的上载,那么它将变成一个复杂的脚本,但是对于小文件来说,这是完全可行的。 You'll need to play around a bit to get the correct encoding, multipart mime body, mime type and content size, but it's all eminently doable. 您需要花点时间才能获得正确的编码,多部分的mime主体,mime类型和内容大小,但这都是可以实现的。 You'll start by calling Google's auth api with your stored refresh token to get an access token. 首先,使用存储的刷新令牌调用Google的auth api,以获取访问令牌。 Then you'll set that access token into an Authorization bearer header as part of your content upload call. 然后,将您的访问令牌设置为授权承载标头,作为内容上传调用的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM