From ef9c6a9c6955e51f2f9a1dbefee0e2ad874e9c29 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Sun, 1 Mar 2026 17:34:02 -0500 Subject: [PATCH] make better --- auth/google_auth.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/auth/google_auth.py b/auth/google_auth.py index f9b7947..93e438e 100644 --- a/auth/google_auth.py +++ b/auth/google_auth.py @@ -295,6 +295,7 @@ def create_oauth_flow( redirect_uri: str, state: Optional[str] = None, code_verifier: Optional[str] = None, + autogenerate_code_verifier: bool = True, ) -> Flow: """Creates an OAuth flow using environment variables or client secrets file.""" flow_kwargs = { @@ -308,10 +309,10 @@ def create_oauth_flow( flow_kwargs["autogenerate_code_verifier"] = False else: # Generate PKCE code verifier for the initial auth flow. - # Without this, oauthlib 3.2+ adds code_challenge to the auth URL - # at the session level, but Flow.code_verifier stays None. - # Google then rejects the token exchange with "Missing code verifier". - flow_kwargs["autogenerate_code_verifier"] = True + # google-auth-oauthlib's from_client_* helpers pass + # autogenerate_code_verifier=None unless explicitly provided, which + # prevents Flow from generating and storing a code_verifier. + flow_kwargs["autogenerate_code_verifier"] = autogenerate_code_verifier # Try environment variables first env_config = load_client_secrets_from_env() @@ -526,6 +527,7 @@ def handle_auth_callback( redirect_uri=redirect_uri, state=state, code_verifier=state_info.get("code_verifier"), + autogenerate_code_verifier=False, ) # Exchange the authorization code for credentials