Skip to content
AsterDriveDeveloper

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.

The complete path is: Google Cloud OAuth application → AsterDrive storage policy → administrator authorization and connection test → policy group rules → user or team assignment.

TaskAdmin entry
Create or edit the policyAdmin → Storage Policies
Copy callback URL, authorize, reauthorize, validateThe policy’s Google Drive authorization panel
Configure routing and target priorityAdmin → Policy Groups
Assign a policy groupUser or team details
Inspect cleanup or migration failuresAdmin → 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. Create or select a dedicated project in Google Cloud Console.
  2. Enable the Google Drive API in the API library.
  3. Configure Google Auth Platform / the OAuth consent screen, application details, and a suitable user type.
  4. Create an OAuth client of type Web application and retain its client ID and secret.
  5. 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.

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.

PoolScope requested by AsterDrive
Regular folder, account root, shared drivehttps://www.googleapis.com/auth/drive
appDataFolderhttps://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.

FieldWhat to enter
OAuth client IDThe Google Web application client’s ID
OAuth client secretThe same client’s secret; required for initial creation
Base pathRelative subfolders beneath the selected root, such as AsterDrive/blobs; empty uses the root directly
Root folder IDThe folder ID from its URL; empty uses the account or selected shared-drive root
Shared drive IDA Google Workspace shared drive, when applicable
Use appDataFolderHidden application data storage; cannot be combined with either ID
Upload transferServer relay or browser direct; server relay is the default
Capacity probe timeoutDefaults 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/callback

When 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.

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.

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.

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.

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.

  1. Save the policy and OAuth application configuration.
  2. Click Authorize and consent using the intended administrator Google account.
  3. After returning to AsterDrive, inspect authorization status.
  4. Validate the credential to check access to the configured pool.
  5. 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.

Both strategies use Google resumable upload. The difference is where the file bytes travel.

StrategyData pathSuitable use
Server relay (server_relay, default)Browser → AsterDrive → Google DriveClients can reach AsterDrive, or a centralized network path is preferred
Browser direct (frontend_direct)Browser → Google DriveClients can reliably reach Google and server bandwidth should be reduced

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.

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.

  • 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-Type and Content-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 Range header 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.

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.

Regular account folders and appDataFolder observe Google about.storageQuota.

ConditionInterpretation
A finite limit and usage are returnedAvailable bytes are max(limit − usage, 0)
Google Workspace pooled storageLimit and usage can describe the organization pool, not dedicated folder space
No limit for an unlimited accountNo finite capacity bound is invented; this is not zero free space
Temporary or incomplete quota responseCapacity is inconclusive and existing admission rules apply
Shared driveThe 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.

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.

Add the policy to a policy group and bind users or teams. In an isolated pool, verify:

  1. Upload an empty file, a small file, and a file larger than 8 MiB, checking the selected policy.
  2. Download and compare content, then exercise Range previews.
  3. For browser direct, also verify CORS requests, reload/resume, and cancellation.
  4. Rename a file and confirm the downloaded name follows AsterDrive.
  5. Delete files, empty trash, and wait for physical cleanup after blob references are released.
  6. 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.

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.

SymptomCheck first
redirect_uri_mismatchExact registered callback URL and the proxy-generated external scheme/hostname
Consent screen denies accessTest-user membership, publication state, Workspace application restrictions
Reauthorization requiredRefresh-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 applicationClient ID and secret belong to the same Web application; save repairs and reauthorize
403 after enabling appDataFolderWhether you saved and reauthorized for drive.appdata; do not assume Testing expiry
Folder/shared-drive permission deniedIDs, drive membership, administrator role; validate and test after repairs
308 during uploadNormal incomplete acknowledgement; investigate only when progress cannot be reconciled or requests fail
Browser-direct upload failsClient-to-Google networking, CORS preflight, browser extensions, enterprise proxies; use relay if needed
Rate limit or temporary failureGoogle quotas, proxies, backend outbound networking; retry without first deleting credentials
Inconclusive capacityUnlimited account, shared drive, or missing quota response; this does not mean zero bytes remain
Missing or duplicate objectManual moves/deletion/copies or altered application metadata; restore the original application and pool first