04-07-2026, 04:04 AM
gdrive v3.9.1 - Linux Server Setup with Google API and OAuth Authentication
Overview
This guide covers installing gdrive v3.9.1 on a Linux server, enabling the Google Drive API, configuring OAuth, and authenticating on a headless server.
Prerequisites
Step 0 - Download and Install gdrive Binary
Run on: Linux Server
Download for x64:
For ARM64 servers use:
Verify the tarball:
Extract and install:
Confirm installation:
Step 1 - Enable Google Drive API
Run on: Google Cloud Console (one-time setup)
Step 2 - Configure OAuth Consent Screen
Run on: Google Cloud Console
Step 3 - Create OAuth Client
Run on: Google Cloud Console
Step 4 - Authenticate gdrive on Headless Linux Server
Option A - SSH Port Forward (Recommended)
Run on: Your local laptop first, then server
On your local laptop open a terminal and run:
Keep this terminal open. Then open a new SSH session to your server:
Paste your Desktop Client ID and Secret when prompted. Copy the Google URL that is printed and open it in your laptop browser. Sign in as a Test user and click Allow. Google will redirect to http://127.0.0.1:8085 and the SSH tunnel will forward it back to the server completing the auth.
Verify on the server:
Option B - Export Token from Laptop and Import to Server
Run on: Your local laptop first, then server
On your laptop:
Copy token to server:
[c
Overview
This guide covers installing gdrive v3.9.1 on a Linux server, enabling the Google Drive API, configuring OAuth, and authenticating on a headless server.
Prerequisites
- Linux server with root or sudo access
- Google Cloud Console account
- SSH access to the server
Step 0 - Download and Install gdrive Binary
Run on: Linux Server
Download for x64:
Code:
wget https://github.com/glotlabs/gdrive/releases/download/3.9.1/gdrive_linux-x64.tar.gzFor ARM64 servers use:
Code:
wget https://github.com/glotlabs/gdrive/releases/download/3.9.1/gdrive_linux-arm64.tar.gzVerify the tarball:
Code:
file gdrive_linux-x64.tar.gzExtract and install:
Code:
tar -xzf gdrive_linux-x64.tar.gz
sudo install -m 0755 ./gdrive /usr/local/bin/gdriveConfirm installation:
Code:
gdrive versionStep 1 - Enable Google Drive API
Run on: Google Cloud Console (one-time setup)
- Open Google Cloud Console and select your project
- Go to APIs & Services > Library
- Search for Google Drive API and click Enable
- Optionally enable Drive Activity API
- Wait 2-3 minutes for changes to propagate
Step 2 - Configure OAuth Consent Screen
Run on: Google Cloud Console
- Go to APIs & Services > OAuth consent screen
- Select User type - External for typical use or Internal for Google Workspace
- Fill in App name, User support email and Developer contact information
- Click Save
- Set Publishing status to Testing
- Go to Audience > Test users and add the Google account you will sign in with
- Note: If your email is not added as a test user you will get 403 access_denied during auth
Step 3 - Create OAuth Client
Run on: Google Cloud Console
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Set Application type to Desktop app - this is critical for loopback redirect
- Copy the Client ID and Client Secret
Step 4 - Authenticate gdrive on Headless Linux Server
Option A - SSH Port Forward (Recommended)
Run on: Your local laptop first, then server
On your local laptop open a terminal and run:
Code:
ssh -N -L 8085:127.0.0.1:8085 root@YOUR_SERVER_IPKeep this terminal open. Then open a new SSH session to your server:
Code:
gdrive account addPaste your Desktop Client ID and Secret when prompted. Copy the Google URL that is printed and open it in your laptop browser. Sign in as a Test user and click Allow. Google will redirect to http://127.0.0.1:8085 and the SSH tunnel will forward it back to the server completing the auth.
Verify on the server:
Code:
gdrive account list
gdrive files listOption B - Export Token from Laptop and Import to Server
Run on: Your local laptop first, then server
On your laptop:
Code:
gdrive account add
gdrive account export > token.jsonCopy token to server:
[c

