From 6919ac552b40fa58c7abfdc74e151c5b9e3d06f6 Mon Sep 17 00:00:00 2001 From: saidsurucu Date: Wed, 2 Jul 2025 00:00:03 +0300 Subject: [PATCH] Update oauth_router.py --- oauth_router.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/oauth_router.py b/oauth_router.py index 92909c6..646b254 100644 --- a/oauth_router.py +++ b/oauth_router.py @@ -238,21 +238,15 @@ async def oauth_callback( "scope": "read search" }) - # Check if this is a ChatGPT callback + # Always redirect back to the original redirect URL if provided original_redirect = redirect_uri or redirect_url - if "chatgpt.com" in (original_redirect or ""): - # For ChatGPT, we need to redirect back with the authorization code - # ChatGPT expects the authorization code to continue the OAuth flow + if original_redirect: + # Redirect back with the authorization code and state return RedirectResponse( url=f"{original_redirect}?code={code}&state={state or ''}" ) - # Return the session token to the client for other clients - # In a real app, you might: - # 1. Set this as an HTTP-only cookie - # 2. Redirect to the frontend with the token - # 3. Store in a secure session store - + # If no redirect URL provided, return JSON response with session token response = JSONResponse(content={ "status": "success", "message": "Authentication successful",