- Your organization restricts third-party app access
- You want full visibility over API usage and quotas in your own Cloud Console
- You’re building a self-hosted or team deployment of Cloudstic
- You want to use a Google service account for unattended automation
Google Drive
Cloudstic reads theGOOGLE_APPLICATION_CREDENTIALS environment variable to load credentials from a JSON file. The same variable works for both a custom OAuth client and a service account. The Google SDK detects which type it is automatically.
Option A: Custom OAuth client
Use this when you want to authenticate as yourself (interactive browser-based login) but under your own Google Cloud project.Create a Google Cloud project
Go to Google Cloud Console and create a new project, or select an existing one.
Enable the Drive API
Navigate to APIs & Services > Library, search for Google Drive API, and click Enable.
Create OAuth credentials
- Go to APIs & Services > Credentials
- Click Create credentials > OAuth client ID
- Choose Desktop app as the application type
- Name it (e.g. “Cloudstic Backup”)
- Click Create, then Download JSON
Configure the OAuth consent screen
If prompted, go to OAuth consent screen and configure it:
- Set User type to Internal (for Google Workspace) or External
- Add the scope
https://www.googleapis.com/auth/drive.readonly - Add your email as a test user if using External type
Set the credentials path
google_token.json (or at GOOGLE_TOKEN_FILE if set) and reused for future backups.Option B: Service account
Use this for automated, unattended backups. No browser is required. A service account authenticates as itself, not as a user.Create a service account
In Google Cloud Console:
- Go to IAM & Admin > Service Accounts
- Click Create service account
- Give it a name and description, then click Create and continue
- Skip role assignment (access is granted via Drive sharing)
- Click Done
Download the key file
- Click the service account you just created
- Go to the Keys tab
- Click Add key > Create new key
- Choose JSON, then click Create
/etc/cloudstic/service-account.json).Grant Drive access
Share the Drive folder or Shared Drive with the service account’s email address:Grant Viewer access. The service account can now read those files.
Securing the credentials file
Store credential files with restricted permissions and never commit them to version control:GOOGLE_APPLICATION_CREDENTIALS in a secured environment file (see Automating Backups):
~/.cloudstic_env
OneDrive
For OneDrive, Cloudstic uses the PKCE public client flow. No client secret is needed. SetONEDRIVE_CLIENT_ID to your Azure app’s client ID to override the built-in app.
Register an app in Azure AD
- Go to Azure Portal > Azure Active Directory > App registrations
- Click New registration
- Name it (e.g. “Cloudstic Backup”)
- Set Redirect URI to
http://localhostwith type Public client/native - Click Register
Configure API permissions
Under API permissions, add the following delegated permissions for Microsoft Graph:
Files.ReadFiles.Read.AllUser.Readoffline_access
Set the environment variable
onedrive_token.json (or at ONEDRIVE_TOKEN_FILE if set).No client secret is required. Cloudstic uses the OAuth 2.0 PKCE flow, which is designed for native and desktop apps and does not require a secret.
Business and education accounts
If you’re backing up a Microsoft 365 or Office 365 account, your organization may block third-party apps by default. Using your own Azure AD app registered within your tenant bypasses this restriction. Contact your IT administrator to:- Register the app in your organization’s Azure AD tenant
- Grant admin consent for the required permissions
- Enable access for the users who will run Cloudstic
Environment variable reference
| Variable | Provider | Description |
|---|---|---|
GOOGLE_APPLICATION_CREDENTIALS | Google Drive | Path to credentials JSON (OAuth client or service account) |
GOOGLE_TOKEN_FILE | Google Drive | Path to cached OAuth token (default: <config-dir>/google_token.json) |
ONEDRIVE_CLIENT_ID | OneDrive | Azure AD app client ID (no secret required) |
ONEDRIVE_TOKEN_FILE | OneDrive | Path to cached OAuth token (default: <config-dir>/onedrive_token.json) |
Next steps
Automating Backups
Schedule unattended backups using cron or systemd
Google Drive Source
Full Google Drive configuration reference
OneDrive Source
Full OneDrive configuration reference
Encryption Keys
Secure your encryption credentials for automation