Commit Graph

66 Commits

Author SHA1 Message Date
Taylor Wilsdon
6a386b4255 refac 2026-03-15 17:29:09 -04:00
Bortlesboat
b7365c661e fix(auth): auto-refresh expired tokens in single-user stdio mode
When credentials had a refresh_token but credentials.expired was False
(e.g., token=None with no stored expiry), the refresh was skipped and
the server would start a new OAuth flow instead. This changes the
condition to attempt refresh whenever credentials are not valid and a
refresh_token is available, regardless of the expired flag.
2026-03-15 17:22:36 -04:00
Taylor Wilsdon
ef9c6a9c69 make better 2026-03-01 17:34:02 -05:00
Baris Sencan
3361ed29e6 Fix PKCE code verifier not being generated for initial OAuth flow
When `create_oauth_flow()` is called without an explicit `code_verifier`
(i.e. during the initial auth flow in `start_auth_flow()`), the function
never sets `autogenerate_code_verifier=True` on the Flow constructor.

oauthlib 3.2+ automatically adds `code_challenge` to the authorization
URL at the session level, so Google expects a matching `code_verifier`
during the token exchange. However, since `Flow.code_verifier` remains
`None`, that `None` gets stored in the session store and later passed
back during the callback — causing Google to reject the token exchange
with `(invalid_grant) Missing code verifier`.

The fix adds `autogenerate_code_verifier=True` in the else branch so
the Flow object generates and exposes a proper PKCE code verifier that
gets stored and reused during the callback token exchange.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:38:29 +00:00
Taylor Wilsdon
8ae833f0c7 Merge branch 'main' of https://github.com/taylorwilsdon/google_workspace_mcp into issues/503 2026-02-28 11:13:23 -04:00
Taylor Wilsdon
9dc9b1c825 pkce fix 2026-02-28 10:06:50 -04:00
Taylor Wilsdon
bb197243cd pr feedback 2026-02-27 16:59:18 -04:00
Taylor Wilsdon
aa520b72d3 fix all them tests 2026-02-24 21:09:14 -04:00
Taylor Wilsdon
f62e0bbd26 pr feedback 2026-02-18 12:28:17 -05:00
github-actions[bot]
950206c707 style: auto-fix ruff lint and format 2026-02-18 16:49:48 +00:00
Taylor Wilsdon
a28fa0a249 address issues/483 2026-02-18 11:48:53 -05:00
Nicholas Xavier Ferrara
eddf940454 fix: add missing token_uri, client_id, client_secret to OAuth 2.1 refresh store_session
The store_session call in the OAuth 2.1 credential refresh path (get_credentials)
omits token_uri, client_id, client_secret, and issuer. These are stored as None,
causing subsequent refresh attempts to fail and forcing full re-authentication.

The correct pattern already exists in three other store_session calls in the same
file (lines 151, 522, 750) — this aligns the refresh path to match.
2026-02-13 13:51:47 -05:00
Taylor Wilsdon
bbee795c16 ruff 2026-02-10 17:22:28 -05:00
Taylor Wilsdon
35fc66f329 persistence call 2026-02-10 17:19:18 -05:00
Taylor Wilsdon
3b75ab11fb fix 448 2026-02-10 17:00:41 -05:00
Taylor Wilsdon
72f06d5853 refac 2026-02-07 13:35:53 -05:00
Taylor Wilsdon
dbab29d356 fix #433 2026-02-07 13:29:22 -05:00
Taylor Wilsdon
bae425f754 refac 2026-02-06 20:33:59 -05:00
Taylor Wilsdon
c7d677ffff refac _find_any_credentials to tuple for legacy mode refresh fix 2026-02-06 10:53:59 -05:00
Chetan Sarva
37d1256efc fix: always close services (to avoid mem leaks) 2026-01-30 10:03:44 -05:00
cvrt-jh
e98bb7115d fix: respect WORKSPACE_MCP_CREDENTIALS_DIR for multi-account support
- Add WORKSPACE_MCP_CREDENTIALS_DIR as primary env var (preferred)
- Keep GOOGLE_MCP_CREDENTIALS_DIR for backward compatibility
- Add os.path.expanduser() to handle ~ in paths
- Add logging to show which credentials directory is being used
- Display credentials directory in startup configuration

This enables running multiple MCP instances with different Google
accounts by configuring separate credential directories.

Fixes #373
2026-01-20 17:07:01 +01:00
Taylor Wilsdon
6b8352a354 apply ruff formatting 2025-12-13 13:49:28 -08:00
Taylor Wilsdon
a60a556359 token refresh uses the embedded creds with optional client secret path 2025-12-08 09:35:40 -05:00
Taylor Wilsdon
238a314fef session binding and legacy compatibility 2025-09-28 16:08:41 -04:00
Taylor Wilsdon
ec9a20d8a3 scope the scopes 2025-08-24 11:15:11 -04:00
Taylor Wilsdon
24abf2a0f0 scope the scopes 2025-08-24 10:37:04 -04:00
Taylor Wilsdon
788e39368d refac decorator, add configure_logt_formatting helper, fixed variable scope & pep8 2025-08-23 12:04:04 -04:00
Taylor Wilsdon
8f9a46e55b implement WORKSPACE_MCP_STATELESS_MODE 2025-08-23 11:12:21 -04:00
Taylor Wilsdon
f1b06446bc WORKSPACE_EXTERNAL_URL - add an document usage 2025-08-22 09:51:49 -04:00
Shawn Zhu
13d0d66f4e doc: how to use credential store 2025-08-17 17:41:23 -04:00
Shawn Zhu
c505a4782b feat: abstract credential store 2025-08-10 18:11:27 -04:00
Taylor Wilsdon
0967594097 completely working 2025-08-05 10:22:01 -04:00
Taylor Wilsdon
bb55feed83 cleanup redundant session stores 2025-08-03 11:12:58 -04:00
Taylor Wilsdon
2836f6c45f refactor to clean up scopes 2025-08-03 10:30:04 -04:00
Taylor Wilsdon
e37803240a everything working, including session correlation and service decorator oauth awareness 2025-08-02 18:50:49 -04:00
Taylor Wilsdon
c45bb3956c oauth2.1 truly works 2025-08-02 18:25:08 -04:00
Taylor Wilsdon
9470a41dde almost there, working out session persistence 2025-08-02 15:40:23 -04:00
Taylor Wilsdon
21ebff4b8a added same server availability check that exists in start_google_auth to the start_auth_flow function 2025-07-26 16:20:57 -04:00
Taylor Wilsdon
f0976514e2 remove mcp session id 2025-07-26 12:05:22 -04:00
Taylor Wilsdon
d4dc255f16 resolve all ruff check errors 2025-07-18 18:04:06 -04:00
Taylor Wilsdon
a2fec7dcdd fix imports in auth 2025-07-10 14:05:08 -04:00
Taylor Wilsdon
6f48a04545 Update stdio startup and credentails path for easier claude desktop autoinstall 2025-07-04 16:10:01 -04:00
Taylor Wilsdon
d275c405f1 Update auth/google_auth.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-28 13:33:44 -07:00
Taylor Wilsdon
33eaa47d0c refactored the credential checking logic into a shared helper function to reduce code duplication 2025-06-28 12:56:43 -07:00
Taylor Wilsdon
5f08c89468 302 GOOGLE_CLIENT_SECRETS to GOOGLE_CLIENT_SECRET_PATH 2025-06-28 12:14:42 -07:00
Taylor Wilsdon
fef8479620 add environment variable support for google oauth client secret file generation with fallback to file based 2025-06-28 12:06:36 -07:00
Taylor Wilsdon
808504928b dedupe, remove circular imports 2025-06-09 17:36:31 -04:00
Taylor Wilsdon
96da15be22 add expiry handling 2025-06-08 12:31:18 -04:00
Taylor Wilsdon
019517beeb respect WORKSPACE_MCP_BASE_URI everywhere 2025-06-08 12:17:06 -04:00
Taylor Wilsdon
05b9ddadb2 gracefully handle refresherrors on expired tokens 2025-06-08 12:04:19 -04:00