oauth window now opening in a small, discreet window

This commit is contained in:
adamhaley
2025-08-15 17:51:22 -07:00
parent 212578b42e
commit 7f30df6c2b
2 changed files with 29 additions and 13 deletions
+5 -4
View File
@@ -153,13 +153,14 @@ class DropboxSetupNode:
oauth_handler.start_oauth_session(session_id, app_key_clean, app_secret_clean)
try:
print(f"[DropboxSetup] Opening browser for automatic OAuth flow...")
webbrowser.open(oauth_url)
message = f"🚀 Automatic OAuth Started!\n\n🌐 Browser opened for authorization. After you authorize in Dropbox, ComfyUI will refresh automatically.\n\n⏳ Waiting for authorization...\n\n🔗 OAuth URL: {oauth_url}"
print(f"[DropboxSetup] Setting up automatic OAuth popup...")
# We'll use JavaScript to open a proper popup window
message = f"🚀 Automatic OAuth Ready!\n\n🖱️ Click the link below to open a small popup window for authorization:\n\n🔗 {oauth_url}\n\n✨ After authorization, the popup will close and ComfyUI will refresh automatically!"
print(f"[DropboxSetup] Session ID: {session_id}")
print(f"[DropboxSetup] Callback URL: {callback_url}")
print(f"[DropboxSetup] OAuth URL ready for popup: {oauth_url}")
except Exception as e:
print(f"[DropboxSetup] Could not auto-open browser: {e}")
print(f"[DropboxSetup] Error setting up OAuth: {e}")
message = f"🔗 Automatic OAuth Setup:\n\nPlease visit this URL to authorize:\n{oauth_url}\n\nAfter authorization, ComfyUI will refresh automatically!"
else:
# Manual OAuth flow (original behavior)
+24 -9
View File
@@ -54,24 +54,39 @@ app.registerExtension({
}, 1500); // Small delay to ensure OAuth processing is complete
},
// Override the webbrowser.open functionality for better popup control
// Override node execution to detect and handle OAuth URLs
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData.name === "DropboxSetupNode") {
console.log("[DropSendNode] Registered DropboxSetupNode enhancement");
// Add custom OAuth popup handling
const originalExecute = nodeType.prototype.onExecuted;
const originalExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(message) {
console.log("[DropSendNode] Node executed with message:", message);
// Check if this execution includes OAuth URL generation
if (message && typeof message === 'string' && message.includes('🚀 Automatic OAuth Started!')) {
console.log("[DropSendNode] Detected automatic OAuth start");
// Extract OAuth URL from the message (it should be in the callback setup)
// We'll enhance this to open a proper popup instead of a full tab
if (message && typeof message === 'object' && message.text && message.text[0]) {
const text = message.text[0];
if (text.includes('🚀 Automatic OAuth Ready!')) {
console.log("[DropSendNode] Detected automatic OAuth ready message");
// Extract OAuth URL from the message
const urlMatch = text.match(/🔗 (https:\/\/www\.dropbox\.com\/oauth2\/authorize[^\s]+)/);
if (urlMatch) {
const oauthUrl = urlMatch[1];
console.log("[DropSendNode] Extracted OAuth URL:", oauthUrl);
// Auto-open the popup after a brief delay
setTimeout(() => {
console.log("[DropSendNode] Auto-opening OAuth popup...");
window.openDropboxOAuth(oauthUrl);
}, 500);
}
}
}
if (originalExecute) {
return originalExecute.apply(this, arguments);
if (originalExecuted) {
return originalExecuted.apply(this, arguments);
}
};
}