Spaces:
Running
Running
Commit
·
7766a3c
1
Parent(s):
183194f
updated api paths
Browse files- backend/api.py +10 -1
backend/api.py
CHANGED
|
@@ -75,7 +75,7 @@ def _client_config():
|
|
| 75 |
@api.get("/oauth/google/start")
|
| 76 |
def oauth_start():
|
| 77 |
# optional CSRF protection
|
| 78 |
-
log.info("
|
| 79 |
state = secrets.token_urlsafe(16)
|
| 80 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 81 |
auth_url, _ = flow.authorization_url(
|
|
@@ -89,6 +89,7 @@ def oauth_start():
|
|
| 89 |
@api.get("/oauth/google/callback")
|
| 90 |
def oauth_callback(request: Request):
|
| 91 |
# Exchange code for tokens
|
|
|
|
| 92 |
full_url = str(request.url) # includes ?code=...
|
| 93 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 94 |
flow.fetch_token(authorization_response=full_url)
|
|
@@ -105,6 +106,14 @@ def health():
|
|
| 105 |
def list_routes():
|
| 106 |
return {"routes": sorted([getattr(r, "path", str(r)) for r in api.router.routes])}
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
@api.get("/debug/env")
|
| 109 |
def debug_env():
|
| 110 |
return {
|
|
|
|
| 75 |
@api.get("/oauth/google/start")
|
| 76 |
def oauth_start():
|
| 77 |
# optional CSRF protection
|
| 78 |
+
log.info(f"OAuth start: redirect_uri={REDIRECT_URI}")
|
| 79 |
state = secrets.token_urlsafe(16)
|
| 80 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 81 |
auth_url, _ = flow.authorization_url(
|
|
|
|
| 89 |
@api.get("/oauth/google/callback")
|
| 90 |
def oauth_callback(request: Request):
|
| 91 |
# Exchange code for tokens
|
| 92 |
+
log.info(f"OAuth callback hit: url={request.url}")
|
| 93 |
full_url = str(request.url) # includes ?code=...
|
| 94 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 95 |
flow.fetch_token(authorization_response=full_url)
|
|
|
|
| 106 |
def list_routes():
|
| 107 |
return {"routes": sorted([getattr(r, "path", str(r)) for r in api.router.routes])}
|
| 108 |
|
| 109 |
+
@api.get("/api/debug/oauth")
|
| 110 |
+
def debug_oauth():
|
| 111 |
+
return {
|
| 112 |
+
"base_url_env": BASE_URL_RAW,
|
| 113 |
+
"base_url_effective": BASE_URL,
|
| 114 |
+
"redirect_uri_built": f"{BASE_URL}/oauth/google/callback"
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
@api.get("/debug/env")
|
| 118 |
def debug_env():
|
| 119 |
return {
|