Update oauth_router.py
This commit is contained in:
+4
-10
@@ -238,21 +238,15 @@ async def oauth_callback(
|
|||||||
"scope": "read search"
|
"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
|
original_redirect = redirect_uri or redirect_url
|
||||||
if "chatgpt.com" in (original_redirect or ""):
|
if original_redirect:
|
||||||
# For ChatGPT, we need to redirect back with the authorization code
|
# Redirect back with the authorization code and state
|
||||||
# ChatGPT expects the authorization code to continue the OAuth flow
|
|
||||||
return RedirectResponse(
|
return RedirectResponse(
|
||||||
url=f"{original_redirect}?code={code}&state={state or ''}"
|
url=f"{original_redirect}?code={code}&state={state or ''}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Return the session token to the client for other clients
|
# If no redirect URL provided, return JSON response with session token
|
||||||
# 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
|
|
||||||
|
|
||||||
response = JSONResponse(content={
|
response = JSONResponse(content={
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"message": "Authentication successful",
|
"message": "Authentication successful",
|
||||||
|
|||||||
Reference in New Issue
Block a user