Skip to content

Conversation

@santiagomed
Copy link
Collaborator

Features and Improvements

  • Integration of OAuth2 Token Validation and Refresh Logic:

    • Implemented a method to validate the OAuth2 token and refresh it if expired in the ApiClient struct.
    • The method validate_and_refresh_oauth2_token checks the current time against the token's expiration time and refreshes the token using oauth2_refresh_token if necessary.
  • Enhanced get_oauth2_token Method:

    • The logic of fetching the OAuth2 token has been refined to first check the token store for existing tokens and validate them. The method now calls validate_and_refresh_oauth2_token to ensure that a valid token is always returned to the caller.
  • Centralized OAuth2 Client Creation:

    • Added a new private method create_oauth2_client within Auth to return a properly configured OAuth2 client.
  • Structured Token Management:

    • Introduced a new OAuth2Token struct to encapsulate access token information, including the access token, refresh token, and expiration time.
    • The token store methods have been updated to save and retrieve the new structured tokens.
  • New Scopes Management:

    • Created an OAuth2Scopes struct to manage and return all necessary OAuth2 scopes in a structured manner, allowing for cleaner additions and modifications to required scopes.

Bug Fixes

  • Error Handling and Reporting:

    • Improved error handling when refreshing tokens and fetching usernames, ensuring proper error messages are returned for various failures.
  • Fixed Refresh Token Management:

    • Ensured that refresh tokens are correctly handled and stored in the token store. Adjustments were made to avoid crashing due to missing refresh tokens.

Additional Changes

  • Updated Testing Logic:

    • Adjusted test cases to accommodate new token structures and refresh logic. Tests now utilize the timestamp to create valid refresh tokens for the mock setup.
  • Code Refactoring:

    • Cleaned up redundant code throughout the ApiClient and Auth modules, improving readability and maintainability.

Development Environment

  • VS Code Debug Configuration:
    • Added a new launch.json configuration file for the VS Code environment to facilitate easier debugging of the application, specifically for the use of the LLDB debugger.

Copy link
Contributor

@tapans tapans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@tapans tapans merged commit 120eafe into main Dec 22, 2024
2 checks passed
@tapans tapans deleted the santiagomed/refresh-token branch December 22, 2024 18:52
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.

3 participants