Google Drive Storage Policy Tutorial
See the provider evidence index for protocol sources, versions, review status and cloud acceptance boundaries. Validate origin APIs, upload endpoints, CDN and custom domains separately.
Separate the configuration layers
Section titled “Separate the configuration layers”The complete path is: Google Cloud OAuth application → AsterDrive storage policy → administrator authorization and connection test → policy group rules → user or team assignment.
| Task | Admin entry |
|---|---|
| Create or edit the policy | Admin → Storage Policies |
| Copy callback URL, authorize, reauthorize, validate | The policy’s Google Drive authorization panel |
| Configure routing and target priority | Admin → Policy Groups |
| Assign a policy group | User or team details |
| Inspect cleanup or migration failures | Admin → Background Tasks |
Google Drive requires a saved application followed by browser authorization. It cannot be the first storage policy during system setup. Complete Local or another immediately verifiable storage setup first, then add Google Drive.
1. Prepare a Google Cloud project
Section titled “1. Prepare a Google Cloud project”- Create or select a dedicated project in Google Cloud Console.
- Enable the Google Drive API in the API library.
- Configure Google Auth Platform / the OAuth consent screen, application details, and a suitable user type.
- Create an OAuth client of type Web application and retain its client ID and secret.
- For an external application in Testing, add the Google account that will authorize AsterDrive as a test user.
This is administrator-consented delegated OAuth. A service account JSON file, an API key, or another application’s secret does not replace the web client’s secret.
Testing applications and token expiry
Section titled “Testing applications and token expiry”Drive refresh tokens issued to external applications in Testing typically expire after seven days. For long-running deployments, complete Google’s publication and any required verification. Organization administrators can also restrict third-party applications and Drive scopes.
Testing and production applications use the same token endpoint and grant_type=refresh_token. The difference is Google’s refresh-token lifetime policy: the seven-day limit applies to external Testing applications requesting Drive scopes, and repeatedly refreshing access tokens does not bypass it. Production applications are not subject to that specific limit, but their refresh tokens are not guaranteed permanent.
A long-running Testing deployment can work for several days and then require reauthorization for uploads, downloads, thumbnails, or cleanup. On the next refresh attempt, invalid_grant makes AsterDrive persist a reauthorization-required credential status. Files are retained; local user login and unrelated storage policies are unaffected. There is no seventh-day scheduled reminder, and the displayed access-token expiry is not the refresh token’s seven-day deadline.
Production refresh tokens can still become invalid after user revocation, six months of disuse, issuance limits invalidating old tokens, time-limited grants, or organization restrictions. After publishing an application, authorize again to obtain fresh credentials; do not assume an older Testing token is automatically extended.
Application secrets, account authorization, and publication status are separate concerns. Changing the secret does not repair a revoked grant; reauthorization does not repair an incorrect client secret.
Requested scopes
Section titled “Requested scopes”| Pool | Scope requested by AsterDrive |
|---|---|
| Regular folder, account root, shared drive | https://www.googleapis.com/auth/drive |
| appDataFolder | https://www.googleapis.com/auth/drive.appdata |
Regular pools use the broad Drive scope. AsterDrive additionally restricts object lookup and deletion to the configured pool and application ownership marker. Use a dedicated application and folder, and review Google’s and your organization’s consent requirements.
2. Create the policy and register its callback
Section titled “2. Create the policy and register its callback”Open Admin → Storage Policies → New Policy and select Google Drive.
| Field | What to enter |
|---|---|
| OAuth client ID | The Google Web application client’s ID |
| OAuth client secret | The same client’s secret; required for initial creation |
| Base path | Relative subfolders beneath the selected root, such as AsterDrive/blobs; empty uses the root directly |
| Root folder ID | The folder ID from its URL; empty uses the account or selected shared-drive root |
| Shared drive ID | A Google Workspace shared drive, when applicable |
| Use appDataFolder | Hidden application data storage; cannot be combined with either ID |
| Upload transfer | Server relay or browser direct; server relay is the default |
| Capacity probe timeout | Defaults to 10 seconds; accepts 2–30 seconds and only controls quota observation |
Save the policy, copy the exact OAuth callback URL from the authorization panel, and add it to the Google client’s Authorized redirect URIs. For example:
https://drive.example.com/api/v1/admin/policies/storage-authorization/callbackWhen editing, omitting or leaving the secret empty preserves the saved secret for the same client ID. Changing the client ID requires a new secret and authorization.
3. Choose the storage pool
Section titled “3. Choose the storage pool”Root folder and base path
Section titled “Root folder and base path”The root folder ID selects a real Google folder; the base path selects relative subfolders beneath it. If the root is TeamStorage and the base path is AsterDrive/blobs, objects are stored in TeamStorage/AsterDrive/blobs. An empty base path retains the existing policy location.
Multilevel and Unicode folder names are supported. Missing folders are created only on writes. Reads, downloads, and deletes never create directories. Ambiguous names, files, and shortcuts in the path fail closed. Do not enter .., backslashes, or a full URL.
Base paths also work in shared drives and appDataFolder. Internal files/... blob keys remain application metadata rather than an additional directory tree. Quota observations still describe the account/organization pool, not dedicated capacity for these folders.
Regular folder
Section titled “Regular folder”For https://drive.google.com/drive/folders/FOLDER_ID, enter FOLDER_ID, not the full URL.
A dedicated empty folder is recommended. Leaving the field empty uses the account root, but makes it harder to distinguish AsterDrive-managed objects from other administrator files.
Google Workspace shared drive
Section titled “Google Workspace shared drive”The shared drive ID defines the search scope. A root folder ID can further restrict the pool to a folder inside that drive. An empty root folder ID uses the shared-drive root.
The administrator needs access, permission to add files, and permission to delete them. Browse-only access is insufficient. Credential validation checks the root and its shared-drive membership; the saved-policy connection test also creates and deletes a test object.
appDataFolder
Section titled “appDataFolder”This hidden space is isolated by application and uses the drive.appdata scope. It is not available in the normal Drive file UI and cannot be shared, moved across spaces, or trashed as ordinary Drive content.
Enable it with both IDs empty. Save and reauthorize after every appDataFolder toggle: normal space requires drive, while hidden application data requires drive.appdata. Saving the setting does not add permissions to the old token. Missing reauthorization can cause a Google HTTP 403; consent again before credential validation and upload testing. This scope mismatch is separate from Testing’s seven-day expiry.
AsterDrive manages file deletion and cleanup; there is no need to manipulate a Google web trash folder.
4. Authorize and validate
Section titled “4. Authorize and validate”- Save the policy and OAuth application configuration.
- Click Authorize and consent using the intended administrator Google account.
- After returning to AsterDrive, inspect authorization status.
- Validate the credential to check access to the configured pool.
- Run the saved-policy connection test to verify temporary object creation and deletion.
The flow uses one-time state and PKCE. The backend encrypts the client secret, access token, and refresh token. Ordinary users do not receive administrator OAuth tokens.
Authorization uses the saved application. If the application, credential, or storage configuration changes during the flow, the stale callback is rejected; start authorization again. An old browser page cannot overwrite the newly saved configuration.
Normal access-token expiry is handled by automatic refresh. Administrator reauthorization is needed when the grant expires or is revoked. Rate limits, proxy errors, and temporary networking failures preserve saved authorization.
5. Choose the upload transfer
Section titled “5. Choose the upload transfer”Both strategies use Google resumable upload. The difference is where the file bytes travel.
| Strategy | Data path | Suitable use |
|---|---|---|
Server relay (server_relay, default) | Browser → AsterDrive → Google Drive | Clients can reach AsterDrive, or a centralized network path is preferred |
Browser direct (frontend_direct) | Browser → Google Drive | Clients can reliably reach Google and server bandwidth should be reduced |
Server relay
Section titled “Server relay”Large files transfer sequentially with at most one 8 MiB fragment buffered at a time. AsterDrive does not buffer the full object in memory. Provider sessions stay encrypted on the backend; browsers call AsterDrive upload endpoints and receive no Google session URL.
The browser only needs AsterDrive connectivity. Primary instances need access to Google OAuth and Drive APIs. Capacity probe deadlines do not change file transfer timeouts.
Browser direct
Section titled “Browser direct”AsterDrive checks permissions, quotas, and placement, then creates the Google upload session on the backend. The browser receives the temporary capability URL for this upload and PUTs the fragments directly. Administrator OAuth tokens remain on the server.
The session URL authorizes this specific upload. Do not publish it in comments, logs, or screenshots. It does not make the entire storage folder publicly shared.
Google acknowledges ordinary intermediate fragments with 308 Resume Incomplete and a Range header. AsterDrive resumes from confirmed bytes. When the response header is not visible to the browser or a response is lost, the browser asks AsterDrive to reconcile progress with the provider.
Browser connectivity and CORS
Section titled “Browser connectivity and CORS”- Both the browser and backend need the appropriate Google connectivity. A server-side proxy does not automatically give user devices direct Google access.
- The browser must allow cross-origin PUT with
Content-TypeandContent-Range. - Direct uploads go straight to the Google session URL, bypassing AsterDrive’s reverse proxy. Headers added by that proxy do not affect Google’s CORS response for this request.
- A hidden
Rangeheader triggers backend progress reconciliation. If the preflight itself is blocked, repair browser connectivity or use server relay.
AsterDrive does not attach its login cookies or CSRF headers to provider upload requests. Browser success still requires backend object and size validation before file publication and quota accounting.
Resume, cancel, and switch strategies
Section titled “Resume, cancel, and switch strategies”After reloading the page, recover the task from AsterDrive’s recoverable uploads and reselect the original file when prompted. Recovery uses the provider-confirmed position. An expired session requires a new upload.
Cancel through AsterDrive to clean up the backend session and temporary object. Aborting a browser request and cancelling the entire upload are separate actions. Inspect background tasks and retry failed cleanup.
Changing the strategy affects newly initialized uploads. An existing upload retains its original session type; editing a policy does not convert an in-progress session.
6. Understand capacity observation
Section titled “6. Understand capacity observation”Regular account folders and appDataFolder observe Google about.storageQuota.
| Condition | Interpretation |
|---|---|
| A finite limit and usage are returned | Available bytes are max(limit − usage, 0) |
| Google Workspace pooled storage | Limit and usage can describe the organization pool, not dedicated folder space |
| No limit for an unlimited account | No finite capacity bound is invented; this is not zero free space |
| Temporary or incomplete quota response | Capacity is inconclusive and existing admission rules apply |
| Shared drive | The administrator’s personal quota is not attributed to the drive; its independent capacity bound is not observable here |
The usage field can include other services such as Gmail and Google Photos. Subtracting only Drive file usage would overstate available capacity.
Observations are cached and are not reservations. Other writers can consume space after a successful observation. Google write results and organization limits still apply.
7. Downloads and filenames
Section titled “7. Downloads and filenames”Google Drive downloads currently stream through AsterDrive, including Range previews. AsterDrive checks access first and returns the current AsterDrive filename. Renaming a file does not require renaming the underlying Google object.
This connector therefore has no OneDrive-style direct-download or provider-native / strict-current filename selector. OneDrive uses preauthenticated download URLs; ordinary Google media requests require authorization. webContentLink and asynchronous files.download results must not be assumed equivalent for distributing private administrator-owned objects. This implementation does not make folders public or expose administrator tokens to create a direct link.
files.download also does not accept appDataFolder’s dedicated scope. Its 24-hour operation lifetime does not establish anonymous download access for 24 hours. Server relay currently provides consistent authorization and filenames across regular folders, shared drives, and appDataFolder.
Google also exposes optional thumbnail links and image/video metadata, but this connector does not currently integrate storage-native processing. AsterDrive continues using its existing thumbnail and media processing chain. Provider API fields alone do not establish product support.
8. Assign a policy group and verify
Section titled “8. Assign a policy group and verify”Add the policy to a policy group and bind users or teams. In an isolated pool, verify:
- Upload an empty file, a small file, and a file larger than 8 MiB, checking the selected policy.
- Download and compare content, then exercise Range previews.
- For browser direct, also verify CORS requests, reload/resume, and cancellation.
- Rename a file and confirm the downloaded name follows AsterDrive.
- Delete files, empty trash, and wait for physical cleanup after blob references are released.
- Inspect capacity, background tasks, and errors. A single connection test does not verify the whole file lifecycle.
Local protocol tests do not replace acceptance against a real Google account, shared-drive roles, and organization policies. Verify each chosen pool and transfer strategy in the deployment’s actual network.
Object ownership and maintenance
Section titled “Object ownership and maintenance”AsterDrive stores the logical key in Google application metadata and scopes lookup/deletion to the configured pool. Multiple objects for one logical key fail closed instead of deleting an arbitrary match.
Do not manually move, delete, or alter application metadata on these objects. Versions, shares, and other references can retain a blob after file deletion. Physical removal follows AsterDrive reference and cleanup rules. Deleting through the Google web UI bypasses those rules.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Check first |
|---|---|
redirect_uri_mismatch | Exact registered callback URL and the proxy-generated external scheme/hostname |
| Consent screen denies access | Test-user membership, publication state, Workspace application restrictions |
| Reauthorization required | Refresh-token expiry/revocation; whether an external application is in Testing and requests scopes beyond basic profile information (including Drive scopes), triggering the seven-day refresh-token limit; offline grant |
| Invalid OAuth application | Client ID and secret belong to the same Web application; save repairs and reauthorize |
| 403 after enabling appDataFolder | Whether you saved and reauthorized for drive.appdata; do not assume Testing expiry |
| Folder/shared-drive permission denied | IDs, drive membership, administrator role; validate and test after repairs |
| 308 during upload | Normal incomplete acknowledgement; investigate only when progress cannot be reconciled or requests fail |
| Browser-direct upload fails | Client-to-Google networking, CORS preflight, browser extensions, enterprise proxies; use relay if needed |
| Rate limit or temporary failure | Google quotas, proxies, backend outbound networking; retry without first deleting credentials |
| Inconclusive capacity | Unlimited account, shared drive, or missing quota response; this does not mean zero bytes remain |
| Missing or duplicate object | Manual moves/deletion/copies or altered application metadata; restore the original application and pool first |