Refactor: Improve auth flow and service initialization#11
Refactor: Improve auth flow and service initialization#11allenhutchison merged 5 commits intomainfrom
Conversation
This commit refactors the authentication and service initialization logic to be more robust and on-demand. Key changes: * **On-demand clients:** Service clients (Docs, Sheets, etc.) are now created on-demand for each request, rather than being initialized once at startup. This ensures that each request has a valid and authenticated client. * **Token auto-refresh:** The `AuthManager` now automatically refreshes expired tokens. * **`auth.clear` tool:** A new `auth.clear` tool has been added to allow users to manually clear their authentication credentials. * **Removed `initialize()`:** The `initialize()` method has been removed from all services, simplifying the service lifecycle. These changes improve the reliability of the extension by preventing authentication errors and making the code easier to maintain.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a great refactoring effort that significantly improves the authentication flow and service initialization. Moving to on-demand client creation makes the services more robust against token expiration, and the automatic token refresh in AuthManager is a key enhancement. The addition of the auth.clear tool is also a thoughtful feature for error recovery. The changes are well-implemented across all services and their corresponding tests. I've found a critical issue that could lead to a server crash and a couple of other points for improvement, but overall this is a solid and valuable change.
… and introduce a manual refresh tool.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request is a significant and well-executed refactor of the authentication and service initialization logic. Moving to on-demand client creation for each request and removing the initialize() methods greatly improves the robustness and simplifies the service lifecycle. The addition of automatic token refreshing in AuthManager, along with the new auth.clear and auth.refreshToken tools, provides a much more resilient authentication flow. The new tests for AuthManager are thorough and cover critical edge cases. I have a couple of suggestions to improve code clarity and maintainability.
…nce auth management utilities
… token expiration issues.
Refactor: Improve auth flow and service initialization
This commit refactors the authentication and service initialization logic to be more robust and on-demand.
Key changes:
AuthManagernow automatically refreshes expired tokens.auth.cleartool: A newauth.cleartool has been added to allow users to manually clear their authentication credentials.initialize(): Theinitialize()method has been removed from all services, simplifying the service lifecycle.These changes improve the reliability of the extension by preventing authentication errors and making the code easier to maintain.