Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
gdrive v3.9.1 - Linux Server Setup with Google API and OAuth Authentication
#1
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
  • 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.gz

For ARM64 servers use:
Code:
wget https://github.com/glotlabs/gdrive/releases/download/3.9.1/gdrive_linux-arm64.tar.gz

Verify the tarball:
Code:
file gdrive_linux-x64.tar.gz

Extract and install:
Code:
tar -xzf gdrive_linux-x64.tar.gz
sudo install -m 0755 ./gdrive /usr/local/bin/gdrive

Confirm installation:
Code:
gdrive version

Step 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_IP

Keep this terminal open. Then open a new SSH session to your server:
Code:
gdrive account add

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:
Code:
gdrive account list
gdrive files list

Option 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.json

Copy token to server:
[c
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)