gildas-lormeau/SingleFile · error · Error

error.message + " (Google Drive)"

Error message

error.message + " (Google Drive)"

What it means

In saveToGDrive, when refreshing the Google OAuth token fails with any message other than "unknown_token", the error is rethrown with an " (Google Drive)" suffix and the original as cause. It means Google Drive token refresh failed for a non-recoverable reason.

Source

Thrown at src/core/bg/downloads.js:542

async function saveToGDrive(taskId, filename, blob, authOptions, uploadOptions) {
	try {
		await getAuthInfo(authOptions);
		const taskInfo = business.getTaskInfo(taskId);
		if (!taskInfo || !taskInfo.cancelled) {
			return await gDrive.upload(filename, blob, uploadOptions, callback => business.setCancelCallback(taskId, callback));
		}
	}
	catch (error) {
		if (error.message == "invalid_token") {
			let authInfo;
			try {
				authInfo = await gDrive.refreshAuthToken();
			} catch (error) {
				if (error.message == "unknown_token") {
					authInfo = await getAuthInfo(authOptions, true);
				} else {
					throw new Error(error.message + " (Google Drive)", { cause: error });
				}
			}
			if (authInfo) {
				await config.setAuthInfo(authInfo);
			} else {
				await config.removeAuthInfo();
			}
			return await saveToGDrive(taskId, filename, blob, authOptions, uploadOptions);
		} else {
			throw new Error(error.message + " (Google Drive)", { cause: error });
		}
	}
}

async function saveToDropbox(taskId, filename, blob, uploadOptions) {
	try {
		await getDropboxAuthInfo();
		const taskInfo = business.getTaskInfo(taskId);

View on GitHub (pinned to 517fb7c5cf)

Solutions

  1. Re-authorize Google Drive access in SingleFile options to obtain fresh tokens
  2. Check error.cause: 'invalid_grant' means the refresh token is dead and re-consent is required
  3. Verify the system clock is accurate (token validation is time-sensitive)
  4. Check Google Cloud OAuth client config if you self-hosted the credentials
Defensive patterns

Strategy: try-catch

Validate before calling

// verify stored auth before saving
const authInfo = await config.getAuthInfo();
if (!authInfo || !authInfo.refreshToken) {
  await getAuthInfo(authOptions, true); // force interactive re-auth
}

Try / catch

try {
  await saveToGDrive(taskId, filename, blob, authOptions, uploadOptions);
} catch (error) {
  if (error.message.endsWith('(Google Drive)') && String(error.cause).includes('invalid_grant')) {
    await getAuthInfo(authOptions, true); // force re-consent
  } else { throw error; }
}

Prevention

When it happens

Trigger: gDrive.refreshAuthToken() rejects with e.g. 'invalid_grant' during saveToGDrive called from downloadContent/downloadCompressedContent; only 'unknown_token' is handled by re-auth, everything else is rethrown.

Common situations: User revoked the app in Google account settings; refresh token expired after 6 months of inactivity or password change; OAuth client credentials changed; Google API quota or server outage.

Related errors


AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01). Data as JSON: /api/errors/916050d9b3098101. Report an issue: GitHub.