Improve Google OAuth compatibility and session handling

Updated Electron window and session configuration to enhance Google OAuth sign-in compatibility, including user agent spoofing, session partitioning, and webview security settings. Added debugging for cookie changes and improved request headers for OAuth flows. Updated renderer code and index.html to use the new session partition and user agent. Added oauth-debug.md to document changes and troubleshooting steps.
This commit is contained in:
2025-08-01 14:14:06 +12:00
parent beb2f6b34f
commit dd82dd3fea
5 changed files with 102 additions and 39 deletions
+3 -1
View File
@@ -63,8 +63,10 @@
<webview id="home-webview"
src="home.html"
preload="../preload.js"
partition="persist:default"
partition="persist:main"
allowpopups
webpreferences="allowRunningInsecureContent=false,javascript=true,webSecurity=true"
useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Nebula/1.0.0"
style="width:100%; height:100%; border:none;">
</webview>
</div>
+8 -2
View File
@@ -122,8 +122,11 @@ function createTab(inputUrl) {
webview.id = `tab-${id}`;
webview.src = resolvedUrl;
webview.setAttribute('allowpopups', '');
webview.setAttribute('partition', 'persist:default');
webview.setAttribute('partition', 'persist:main');
webview.setAttribute('preload', '../preload.js');
// Add attributes needed for Google OAuth and sign-in flows
webview.setAttribute('webpreferences', 'allowRunningInsecureContent=false,javascript=true,webSecurity=true');
webview.setAttribute('useragent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Nebula/1.0.0');
webview.addEventListener('page-favicon-updated', e => {
if (e.favicons.length > 0) updateTabMetadata(id, 'favicon', e.favicons[0]);
@@ -289,8 +292,11 @@ function convertHomeTabToWebview(tabId, inputUrl, resolvedUrl) {
webview.id = `tab-${tabId}`;
webview.src = resolvedUrl;
webview.setAttribute('allowpopups', '');
webview.setAttribute('partition', 'persist:default');
webview.setAttribute('partition', 'persist:main');
webview.setAttribute('preload', '../preload.js');
// Add attributes needed for Google OAuth and sign-in flows
webview.setAttribute('webpreferences', 'allowRunningInsecureContent=false,javascript=true,webSecurity=true');
webview.setAttribute('useragent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Nebula/1.0.0');
// Add event listeners
webview.addEventListener('did-fail-load', handleLoadFail(tabId));