Fix x-cli me bookmarks by adding oauth2 login flow#5
Open
alexg0 wants to merge 4 commits intoInfatoshi:mainfrom
Open
Fix x-cli me bookmarks by adding oauth2 login flow#5alexg0 wants to merge 4 commits intoInfatoshi:mainfrom
alexg0 wants to merge 4 commits intoInfatoshi:mainfrom
Conversation
Author
|
This fixes #4. |
Move rotating OAuth2 token state (access/refresh/expiry) out of ~/.config/x-cli/.env into ~/.config/x-cli/.env.auth2 while keeping static OAuth and app config in .env. Implementation details: - add get_config_auth2_env_path() and load order that overlays .env.auth2 over .env - auto-migrate legacy token keys from .env -> .env.auth2 - make migration best-effort so commands do not fail when .env.auth2 is not writable - persist/clear OAuth2 tokens from auth login/logout and refresh flows in .env.auth2 - update docs for static vs mutable env files and migration behavior - add tests for env precedence, migration, and unwritable destination fallback
Consolidate repeated OAuth2 request, URL query, and user-id plumbing across API helpers and CLI command handlers while preserving existing behavior. What changed: - oauth2.py: split legacy token migration into focused read/write/remove helpers and simplify orchestrating flow. - api.py: add shared _request, _query_url, and _get_user_id helpers; route bookmark and related endpoints through common logic. - cli.py: add helper wrappers for repeated command glue (output formatting, tweet-id resolution, identity lookup, OAuth2 status lines). Why: - Reduce duplicate code and branching complexity in the OAuth2 branch. - Make bookmark-oriented OAuth2 login/usage paths easier to maintain. Verification: - UV_CACHE_DIR=.uv-cache uv run ruff check - UV_CACHE_DIR=.uv-cache uv run pytest -q (51 passed)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added following commands:
This requires additional ENV variables