Spaces:
Sleeping
Sleeping
Commit
·
fba3bad
1
Parent(s):
ed93db5
updated g-cal
Browse files- backend/api.py +2 -3
- backend/g_cal.py +0 -1
backend/api.py
CHANGED
|
@@ -27,13 +27,11 @@ from .agent import app as lg_app
|
|
| 27 |
|
| 28 |
api = FastAPI(title="LangGraph Chat API")
|
| 29 |
|
| 30 |
-
SCOPES = ["https://www.googleapis.com/auth/calendar.events"]
|
| 31 |
CLIENT_ID = os.getenv("GOOGLE_CLIENT_ID")
|
| 32 |
CLIENT_SECRET = os.getenv("GOOGLE_CLIENT_SECRET")
|
| 33 |
BASE_URL_RAW = os.getenv("PUBLIC_BASE_URL", "http://localhost:8000")
|
| 34 |
BASE_URL = BASE_URL_RAW.rstrip("/") # no trailing slash
|
| 35 |
REDIRECT_URI = f"{BASE_URL}/oauth/google/callback"
|
| 36 |
-
TOKEN_FILE = Path("/data/google_token.json")
|
| 37 |
|
| 38 |
# CORS (handy during dev; tighten in prod)
|
| 39 |
api.add_middleware(
|
|
@@ -174,9 +172,10 @@ def google_health():
|
|
| 174 |
|
| 175 |
@api.get("/oauth/google/start")
|
| 176 |
def oauth_start():
|
|
|
|
| 177 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 178 |
auth_url, _ = flow.authorization_url(
|
| 179 |
-
access_type="offline", include_granted_scopes=
|
| 180 |
)
|
| 181 |
log.info(f"OAuth start: redirect_uri={REDIRECT_URI}")
|
| 182 |
return RedirectResponse(url=auth_url)
|
|
|
|
| 27 |
|
| 28 |
api = FastAPI(title="LangGraph Chat API")
|
| 29 |
|
|
|
|
| 30 |
CLIENT_ID = os.getenv("GOOGLE_CLIENT_ID")
|
| 31 |
CLIENT_SECRET = os.getenv("GOOGLE_CLIENT_SECRET")
|
| 32 |
BASE_URL_RAW = os.getenv("PUBLIC_BASE_URL", "http://localhost:8000")
|
| 33 |
BASE_URL = BASE_URL_RAW.rstrip("/") # no trailing slash
|
| 34 |
REDIRECT_URI = f"{BASE_URL}/oauth/google/callback"
|
|
|
|
| 35 |
|
| 36 |
# CORS (handy during dev; tighten in prod)
|
| 37 |
api.add_middleware(
|
|
|
|
| 172 |
|
| 173 |
@api.get("/oauth/google/start")
|
| 174 |
def oauth_start():
|
| 175 |
+
log.info(f"🔐 OAuth start: redirect_uri={REDIRECT_URI}")
|
| 176 |
flow = Flow.from_client_config(_client_config(), scopes=SCOPES, redirect_uri=REDIRECT_URI)
|
| 177 |
auth_url, _ = flow.authorization_url(
|
| 178 |
+
access_type="offline", include_granted_scopes=False, prompt="consent"
|
| 179 |
)
|
| 180 |
log.info(f"OAuth start: redirect_uri={REDIRECT_URI}")
|
| 181 |
return RedirectResponse(url=auth_url)
|
backend/g_cal.py
CHANGED
|
@@ -4,7 +4,6 @@ from google.oauth2.credentials import Credentials
|
|
| 4 |
from googleapiclient.discovery import build
|
| 5 |
|
| 6 |
log = logging.getLogger("g_cal")
|
| 7 |
-
|
| 8 |
SCOPES = ["https://www.googleapis.com/auth/calendar.events"]
|
| 9 |
TOKEN_FILE = Path(os.getenv("GCAL_TOKEN_PATH", "/data/google_token.json"))
|
| 10 |
|
|
|
|
| 4 |
from googleapiclient.discovery import build
|
| 5 |
|
| 6 |
log = logging.getLogger("g_cal")
|
|
|
|
| 7 |
SCOPES = ["https://www.googleapis.com/auth/calendar.events"]
|
| 8 |
TOKEN_FILE = Path(os.getenv("GCAL_TOKEN_PATH", "/data/google_token.json"))
|
| 9 |
|