get-google-drive-oauth-token-cli
v1.0.0
Published
Interactive CLI to generate Google OAuth2 tokens for Google Drive and browse/select a Drive folder.
Maintainers
Readme
get-google-drive-oauth-token-cli
Interactive CLI to generate Google OAuth2 tokens for Google Drive. It spins up a temporary local server to capture the OAuth redirect, exchanges the code for tokens, and then lets you browse and select a Drive folder.
Requirements
- Node.js >= 18
- A Google OAuth Client of type Desktop app (create one in the
Google Cloud Console).
The dynamic loopback port (
http://localhost:<port>) only works for the "Desktop app" client type; a "Web application" client would require the exact redirect URI to be pre-registered.
Usage
Run it directly with npx (no install required):
npx oauth-gdrive-tokenOr install it globally:
npm install -g get-google-drive-oauth-token-cli
oauth-gdrive-tokenFlow
- You are prompted for your OAuth Client ID and Client Secret.
- The tool opens your browser with Google's consent screen (and prints the URL in case it doesn't open automatically).
- After you authorize, the local callback server captures the authorization code and exchanges it for tokens.
- You can browse your Drive folders interactively and optionally select one.
- The result (tokens + selected folder) is printed to stdout as JSON.
Scopes
https://www.googleapis.com/auth/drive.file— upload/manage files created by the app.https://www.googleapis.com/auth/drive.metadata.readonly— read Drive metadata to list/browse folders.
Development
npm install
npm run dev # run from source with tsx
npm run build # compile TypeScript to dist/
npm start # run the compiled CLILicense
MIT
