Skip to content

Feature Request: Allow providing GitHub Token for authenticated requests and cache invalidation/refresh #120

Description

@Muromi-Rikka

Currently, ungh provides a convenient way to fetch data from the GitHub API. While ungh might employ caching (or could potentially benefit from it) to mitigate this for repeated requests, there are scenarios where:

  1. The cached data might become stale, and a user might want to force a refresh or check for updates using conditional requests (like If-None-Match or If-Modified-Since).
  2. Performing these cache validation/refresh requests reliably requires higher rate limits available only to authenticated users.
  3. Users might simply prefer to use their personal token for all interactions to leverage higher rate limits consistently, even when dealing with potentially cached data.

There doesn't seem to be a documented way to provide a personal GitHub token specifically to influence how ungh handles requests related to its cache (e.g., forcing a revalidation using the authenticated request).

I propose adding a mechanism to allow users to provide their GitHub Personal Access Token (PAT) when making requests with ungh. This token should then be used for the underlying Workspace call.

Specifically, this feature should enable:

  1. Authenticated Requests: The request to the GitHub API should use the provided token in the Authorization header.
  2. Cache Interaction: When a token is provided, ungh's caching logic (if present/implemented) should ideally leverage the authenticated request. This could mean:
    • Using the token to perform conditional requests (checking ETag/Last-Modified) against the GitHub API to see if the cached data is still valid, benefiting from the higher rate limit for these checks.
    • Potentially offering an option (e.g., a flag like forceRefresh: true alongside the token) to explicitly bypass the cache and fetch fresh data using the authenticated request.

Thank you for considering this feature request and for maintaining ungh!

Additional information

  • Would you be willing to help implement this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions