oauth fixes

This commit is contained in:
adamhaley
2025-08-19 16:50:07 -07:00
parent 23044e5351
commit 787ae3ecf1
3 changed files with 19 additions and 7 deletions
+3 -2
View File
@@ -71,8 +71,9 @@ def setup_keyring_backend():
print(f"[DropboxAuthManager] File keyring also failed: {file_error}")
return False
except ImportError:
print("[DropboxAuthManager] keyrings.alt not available - install with: pip install keyrings.alt")
except ImportError as e:
print(f"[DropboxAuthManager] keyrings.alt not available: {e}")
print("[DropboxAuthManager] Install with: pip install keyrings.alt")
return False
except Exception as e:
+13 -4
View File
@@ -14,7 +14,7 @@ class OAuthCallbackHandler:
self.app_secret = None
self.completion_callback = None
def start_oauth_session(self, session_id, app_key, app_secret, completion_callback=None, storage_method="keyring", dropbox_folder="/Apps/ComfyUI_Output_Files"):
def start_oauth_session(self, session_id, app_key, app_secret, completion_callback=None, storage_method="keyring", dropbox_folder="/Apps/ComfyUI_Output_Files", original_redirect_uri=None):
"""Start a new OAuth session and store the credentials for callback processing"""
print(f"[OAuthHandler] Starting OAuth session: {session_id}")
@@ -32,6 +32,7 @@ class OAuthCallbackHandler:
'completion_callback': completion_callback,
'storage_method': storage_method,
'dropbox_folder': dropbox_folder,
'original_redirect_uri': original_redirect_uri, # Store the original redirect URI
'handler': self
}
@@ -463,9 +464,17 @@ async def handle_oauth_callback(request):
session_data = pending_oauth_sessions[session_id]
handler = session_data['handler']
# Process the callback with the dynamic redirect URI
base_url = get_server_base_url(request)
callback_url = f"{base_url}/oauth/dropbox/callback"
# Use the original redirect URI that was used for authorization (not the detected one)
original_callback_url = session_data.get('original_redirect_uri')
if original_callback_url:
print(f"[OAuthCallback] Using stored redirect URI: {original_callback_url}")
callback_url = original_callback_url
else:
# Fallback to dynamic detection
base_url = get_server_base_url(request)
callback_url = f"{base_url}/oauth/dropbox/callback"
print(f"[OAuthCallback] Using detected redirect URI: {callback_url}")
success, message = await handler.process_callback(auth_code, redirect_uri=callback_url)
# Clean up the session
+3 -1
View File
@@ -239,12 +239,14 @@ class DropboxSetupNode:
# Automatic OAuth flow with callback
session_id = str(uuid.uuid4())
base_url = get_server_base_url()
print(f"[DropboxSetup] Detected base URL: {base_url}")
callback_url = f"{base_url}/oauth/dropbox/callback"
print(f"[DropboxSetup] Using callback URL: {callback_url}")
oauth_url = auth_temp.get_oauth_url(redirect_uri=callback_url, state=session_id)
# Set up OAuth session for callback handling
oauth_handler = OAuthCallbackHandler()
oauth_handler.start_oauth_session(session_id, app_key_clean, app_secret_clean, storage_method=storage_method, dropbox_folder=dropbox_dest_folder)
oauth_handler.start_oauth_session(session_id, app_key_clean, app_secret_clean, storage_method=storage_method, dropbox_folder=dropbox_dest_folder, original_redirect_uri=callback_url)
try:
print(f"[DropboxSetup] Setting up automatic OAuth popup...")