Repository navigation
PyDrive2 2.0: switch to google-auth and require a fresh user login - #395
Conversation
shcheklein
left a comment
There was a problem hiding this comment.
[AI generated — Copilot]
Reviewed the google-auth / google-auth-oauthlib migration in #395. Overall the migration is clean and well-structured (symlink protection, atomic writes, AuthorizedHttp refresh persistence, PKCS12 support via cryptography, and v2 fsspec cache separation are all solid). I left a few inline comments on concrete edge cases and a dependency floor mismatch.
085d40b to
cefd456
Compare
49c72dc to
8a31910
Compare
8a31910 to
04ca8b6
Compare
# Conflicts: # docs/filelist.rst # docs/filemanagement.rst # docs/fsspec.rst # docs/oauth.rst
There was a problem hiding this comment.
🔵 Needs a closer look
The authentication migration needs human end-to-end validation of real Google OAuth callbacks and PKCE beyond mocked tests, and the confirmed Windows Python 3.15 frozen-executable failure requires a release-risk decision.
No open issues 🎉
What changed in this PR
Migrates PyDrive2’s authentication to google-auth for 2.0, removing the deprecated oauth2client stack and requiring a fresh OAuth user login while retaining service-account key authentication.
Changes:
- Replaces authentication dependencies, removes pyOpenSSL and the cryptography upper bound, and switches command-line login to a loopback callback.
- Adds user credential storage with refresh-token persistence and a separate default cache for fsspec/DVC.
- Adds offline authentication regression tests, documents migration requirements, and reformats documentation.
| File | Description |
|---|---|
| README.rst | Reformats links, badges, and examples. |
| pyproject.toml | Replaces OAuth dependencies and removes signing-related upper bounds. |
| pydrive2/test/test_oauth.py | Replaces service-cache tests with an offline storage-reuse check. |
| pydrive2/test/test_auth_flows.py | Adds coverage for login, refresh, persistence, signing, and file safety. |
| pydrive2/test/settings/test_oauth_test_09.yaml | Removes the obsolete storage-reuse fixture. |
| pydrive2/test/settings/test_oauth_test_07.yaml | Removes the saved service-account cache fixture. |
| pydrive2/test/settings/test_oauth_test_06.yaml | Removes the deprecated PKCS12 cache fixture. |
| pydrive2/test/README.rst | Reformats test setup instructions and corrects numbering. |
| pydrive2/settings.py | Changes the default redirect URI to localhost. |
| pydrive2/fs/spec.py | Separates the default cache and exposes credential migration errors. |
| pydrive2/auth.py | Migrates OAuth flows, service signing, refresh, and authorized transports. |
| pydrive2/_credentials.py | Adds user credential serialization, locked refresh persistence, and atomic writes. |
| docs/quickstart.rst | Reformats setup instructions and code examples. |
| docs/pydrive2.rst | Corrects an API documentation heading underline. |
| docs/oauth.rst | Documents loopback login, credential persistence, and migration requirements. |
| docs/index.rst | Reformats introductory text and project links. |
| docs/fsspec.rst | Adds cache migration guidance for fsspec and DVC users. |
| docs/filemanagement.rst | Reformats file-management examples and references. |
| docs/filelist.rst | Reformats listing examples and references. |
| CONTRIBUTING.rst | Reformats contributor instructions and links. |
Review effort: Balanced
shcheklein
left a comment
There was a problem hiding this comment.
[AI generated — Copilot]
Re-reviewed #395 at 8fd2074. All earlier review items look well-addressed — the lock-coordinated shared-cache refresh (_pydrive2_session / _pending_refresh), RSASigner PKCS12 support, Refresh() locking, and Windows DACL preservation are clean and thoroughly tested. I left 3 inline comments on concrete edge cases in Windows reparse-point handling, CredentialStore.load() locking on Windows, and _load_credentials() probing the default client_secrets.json.

PyDrive2 2.0 switches to google-auth and google-auth-oauthlib. This removes the
pyOpenSSL dependency and the cryptography upper bound that were needed for
service-account signing with oauth2client. The existing file and dictionary
backends now save google-auth user credentials and persist refreshed tokens.
Clients sharing a cache coordinate refreshes. On Windows, a replacement
credential file receives its access permissions before token data is written.
Upgrading from 1.x
The fsspec adapter and DVC use a separate default cache for 2.x. For an
explicitly configured cache, select a fresh file or dictionary key. For CI
that stores a user token in
GDRIVE_CREDENTIALS_DATA, provision the newlysaved JSON before upgrading the job. The project's live CI uses a separate
service-account key in
GDRIVE_USER_CREDENTIALS_DATAand can keep using it.Deployments that ran solely from a saved 1.x service-account cache need to
provision the signing key. User credential caches no longer store it.
CommandLineAuth()replaces the out-of-band flow reported in deprecation of OAuth out-of-band (OOB) in Google OAuth #173 with aloopback callback. It prints a URL to open in a browser. The browser
must be able to reach that port. For custom web callbacks, retain the
original flow and its PKCE verifier through the code exchange.
GoogleAuth.credentialsdirectly now uses google-authobjects. For example, use
credentials.tokento read the access token.Validation
locally. They also passed on 3.11 with the minimum Google auth and filelock
dependencies. Windows CI also covers credential-file permissions and reading
a WOF-compressed credential file.
and the Sphinx documentation build passed.
and reused the rotated token. A built-wheel test exercised a loopback login,
PKCE exchange, and fsspec file and JSON credentials using simulated Google
responses. The upgrade test checks that the old cache stays intact.
temporarily skipped on Windows with Python 3.15 pending Verify the PyInstaller fix for missing python3t.dll on Windows Python 3.15 #399.
Fixes #89, fixes #361, fixes #369, fixes #374. Supersedes #391, #392,
and #398.