简体   繁体   English

如何从CLI(不使用浏览器)和使用OAuth2使用Google Drive API?

[英]How can i use Google Drive API from a CLI (without browser) and using OAuth2?

Is it possible to authenticate and get the access token only using CLI? 是否可以仅使用CLI进行身份验证并获取访问令牌? I don't have a browser (for the OAuth2 consent part) and i need to authenticate and request resources using the REST API. 我没有浏览器(用于OAuth2同意部分),我需要使用REST API对资源进行身份验证和请求。

The short answer is no. 最简洁的答案是不。 Google OAuth for User Credentials is performed by a web browser. Google OAuth for User Credentials由网络浏览器执行。

If you also have a Google Cloud account, there are ways to create OAuth Access Tokens, but these are short-lived (3600 seconds). 如果您还拥有Google Cloud帐户,则可以通过多种方式创建OAuth访问令牌,但这些是短暂的(3600秒)。 Then there is G Suite Domain-Wide delegation that uses a Google Cloud Service Account. 然后是使用Google Cloud Service帐户的G Suite Domain-Wide委派。

I wrote an article on how to do OAuth using curl but this still requires a web browser, but you can save the tokens and use on a remote device. 我写了一篇关于如何使用curl进行OAuth的文章,但这仍然需要一个Web浏览器,但您可以保存令牌并在远程设备上使用。 link . 链接

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

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