Skip to content

Extend ClientOAuthProvider with Pluggable Token Storage for Offline Use #749

@anktsrkr

Description

@anktsrkr

Is your feature request related to a problem? Please describe.
Based on the analysis of the ClientOAuthProvider.cs, my understanding is -

Storage Mechanism

  • Refresh tokens are stored in-memory within the ClientOAuthProvider instance
  • They're held in a TokenContainer assigned to the private field _token

Management Patterns

  1. Automatic Refresh: The GetCredentialAsync method checks access token validity and automatically uses the stored refresh token to obtain a new access token when needed

  2. Refresh Process: The RefreshTokenAsync method sends a request to the OAuth server using the refresh_token grant type. On success, it receives a new TokenContainer (with potentially a new refresh token) which replaces the old _token object

  3. In-Memory Only: This is explicitly a "generic implementation" that holds tokens in memory without giving ability to persist.

  4. Lifecycle: The refresh token's lifecycle is tied to the ClientOAuthProvider instance - if the instance is garbage collected or the application restarts, the refresh token is lost.

Describe the solution you'd like
If user gives offline_access, I want to implement persistent storage for refresh tokens. So that it can be -

  1. Sent persisted refresh_token through SseClientTransport and SDK handles getting access_token and also ability to persist the new refresh token
  2. Manually get the new access_token and send it through SseClientTransport

Or, some sort of Token Store Abstraction with default implementation and inject this store into ClientOAuthProvider.

Describe alternatives you've considered
May be fork and make the things work, but issue will be with maintainability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions