{"record":{"id":"b3519cfb12b0cd83","repo":"gildas-lormeau/SingleFile","slug":"auth-not-supported","errorCode":"auth_not_supported","errorMessage":"auth_not_supported","messagePattern":"auth_not_supported","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/gdrive/gdrive.js","lineNumber":306,"sourceCode":"\ttry {\n\t\tif (nativeWebAuthFlowSupported() && !options.forceWebAuthFlow) {\n\t\t\tconst authURL = await browser.identity.launchWebAuthFlow({\n\t\t\t\tinteractive: options.interactive,\n\t\t\t\turl: gdrive.authURL\n\t\t\t});\n\t\t\tconst searchParams = new URLSearchParams(new URL(authURL).search);\n\t\t\tif (searchParams.get(\"state\") != state) {\n\t\t\t\tthrow new Error(\"invalid_auth_response\");\n\t\t\t}\n\t\t\toptions.code = searchParams.get(\"code\");\n\t\t\treturn await authFromCode(gdrive, options);\n\t\t} else if (options.launchWebAuthFlow) {\n\t\t\toptions.extractAuthCode(browser.identity.getRedirectURL(), authFlow)\n\t\t\t\t.then(authCode => code = authCode)\n\t\t\t\t.catch(() => { /* ignored */ });\n\t\t\treturn await options.launchWebAuthFlow({ url: gdrive.authURL }, authFlow);\n\t\t} else {\n\t\t\tthrow new Error(\"auth_not_supported\");\n\t\t}\n\t}\n\tcatch (error) {\n\t\tif (error.message && (error.message == \"code_required\" || error.message.includes(\"access\"))) {\n\t\t\tif (code) {\n\t\t\t\toptions.code = code;\n\t\t\t\treturn await authFromCode(gdrive, options);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\"code_required\", { cause: error });\n\t\t\t}\n\t\t} else {\n\t\t\tthrow error;\n\t\t}\n\t}\n\tfinally {\n\t\tif (authFlow.cancel) {\n\t\t\tauthFlow.cancel();\n\t\t}","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/lib/gdrive/gdrive.js#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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});","If you already have an auth code, pass options.code (or provide extractAuthCode) so initAuth can use authFromCode instead of launching a flow.","Check which auth paths your environment supports (extension vs web) and supply the matching option."],"exampleFix":"// before\nawait gdrive.auth({});\n// after\nawait gdrive.auth({\n  launchWebAuthFlow: (url) => browser.identity.launchWebAuthFlow({ interactive: true, url })\n});","handlingStrategy":"validation","validationCode":"function canAuth(options) {\n  return typeof options.launchWebAuthFlow === \"function\" || typeof options.code === \"string\" && options.code.length > 0;\n}\nif (!canAuth(options)) throw new Error(\"configure an auth flow before calling auth()\");","typeGuard":null,"tryCatchPattern":"try { await gdrive.auth(options); }\ncatch (e) { if (e.message === \"auth_not_supported\") { setupAuthFlow(); } else throw e; }","preventionTips":["Always pass launchWebAuthFlow (or options.code) when initializing gdrive auth","Write a unit test asserting auth options are complete for each environment","Keep the options object shape in one shared factory to avoid key drift"],"tags":["oauth","auth","configuration","gdrive"],"backgroundTag":"oauth-flow-not-configured","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}