gildas-lormeau/SingleFile · error · Error

auth_not_supported

auth_not_supported

Error message

auth_not_supported

What it means

initAuth throws "auth_not_supported" when none of the supported OAuth launch mechanisms are configured. The library supports interactive browser auth flows (e.g. launchWebAuthFlow via browser.identity) and other explicit auth options; if the caller supplied none of them, there is no way to obtain an auth code, so it fails fast instead of hanging.

Source

Thrown at src/lib/gdrive/gdrive.js:306

	try {
		if (nativeWebAuthFlowSupported() && !options.forceWebAuthFlow) {
			const authURL = await browser.identity.launchWebAuthFlow({
				interactive: options.interactive,
				url: gdrive.authURL
			});
			const searchParams = new URLSearchParams(new URL(authURL).search);
			if (searchParams.get("state") != state) {
				throw new Error("invalid_auth_response");
			}
			options.code = searchParams.get("code");
			return await authFromCode(gdrive, options);
		} else if (options.launchWebAuthFlow) {
			options.extractAuthCode(browser.identity.getRedirectURL(), authFlow)
				.then(authCode => code = authCode)
				.catch(() => { /* ignored */ });
			return await options.launchWebAuthFlow({ url: gdrive.authURL }, authFlow);
		} else {
			throw new Error("auth_not_supported");
		}
	}
	catch (error) {
		if (error.message && (error.message == "code_required" || error.message.includes("access"))) {
			if (code) {
				options.code = code;
				return await authFromCode(gdrive, options);
			} else {
				throw new Error("code_required", { cause: error });
			}
		} else {
			throw error;
		}
	}
	finally {
		if (authFlow.cancel) {
			authFlow.cancel();
		}

View on GitHub (pinned to 517fb7c5cf)

Solutions

  1. Pass a launchWebAuthFlow function in options that opens gdrive.authURL and resolves with the redirect URL, e.g. options.launchWebAuthFlow = (url) => browser.identity.launchWebAuthFlow({interactive: true, url});
  2. If you already have an auth code, pass options.code (or provide extractAuthCode) so initAuth can use authFromCode instead of launching a flow.
  3. Check which auth paths your environment supports (extension vs web) and supply the matching option.

Example fix

// before
await gdrive.auth({});
// after
await gdrive.auth({
  launchWebAuthFlow: (url) => browser.identity.launchWebAuthFlow({ interactive: true, url })
});
Defensive patterns

Strategy: validation

Validate before calling

function canAuth(options) {
  return typeof options.launchWebAuthFlow === "function" || typeof options.code === "string" && options.code.length > 0;
}
if (!canAuth(options)) throw new Error("configure an auth flow before calling auth()");

Try / catch

try { await gdrive.auth(options); }
catch (e) { if (e.message === "auth_not_supported") { setupAuthFlow(); } else throw e; }

Prevention

When it happens

Trigger: Calling auth()/initAuth with an options object that has no launchWebAuthFlow (and no other supported auth path such as an existing code or extractAuthCode-compatible flow). E.g. calling auth({}) or forgetting to pass launchWebAuthFlow in an environment where browser.identity is available.

Common situations: Building a browser extension and forgetting to wire options.launchWebAuthFlow; running the code in a plain web page or Node script where only the launchWebAuthFlow path exists but it was not provided; renaming/refactoring the options object so the key no longer matches what initAuth reads.

Related errors


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