简体   繁体   中英

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? I don't have a browser (for the OAuth2 consent part) and i need to authenticate and request resources using the REST API.

The short answer is no. Google OAuth for User Credentials is performed by a web browser.

If you also have a Google Cloud account, there are ways to create OAuth Access Tokens, but these are short-lived (3600 seconds). Then there is G Suite Domain-Wide delegation that uses a Google Cloud Service Account.

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. link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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