Skip to content

Ignore corrupt refresh token file instead of failing authentication (#268) - #974

Open
omaraldulimay wants to merge 1 commit into
Open-EO:masterfrom
omaraldulimay:refresh-token-store-corrupt-268
Open

omaraldulimay wants to merge 1 commit into
Open-EO:masterfrom
omaraldulimay:refresh-token-store-corrupt-268

Conversation

@omaraldulimay

Copy link
Copy Markdown

Fixes #268

What changed

  • RefreshTokenStore.get_refresh_token() now logs a warning and returns None when the refresh token file is corrupt, so authenticate_oidc() falls back to the device code flow instead of crashing.
  • RefreshTokenStore.set_refresh_token() now logs a warning and starts from an empty dict when the file is corrupt, so the new refresh token overwrites the broken file.
  • Both use one small private helper. PrivateJsonFile.load() and AuthConfig are unchanged.

Tests

  • Unit tests in tests/rest/auth/test_config.py for get_refresh_token and set_refresh_token with a corrupt file (including warning checks).
  • Integration style test in tests/rest/test_connection.py: with a corrupt refresh token file, authenticate_oidc() falls back to the device flow and stores the new refresh token.
  • pytest tests/rest/auth tests/rest/test_connection.py: 512 passed.

This PR was drafted with the help of Claude Code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better handling of corrupt config/refresh token file

1 participant