Skip to content

Add automatic JWT token refresh capability for long running jobs#52

Open
maclarel wants to merge 2 commits intoSpecterOps:mainfrom
maclarel:refresh_jwt
Open

Add automatic JWT token refresh capability for long running jobs#52
maclarel wants to merge 2 commits intoSpecterOps:mainfrom
maclarel:refresh_jwt

Conversation

@maclarel
Copy link
Copy Markdown
Contributor

@maclarel maclarel commented Apr 21, 2026

JWTs granted through GitHub App usage have a ~1 hour lifespan, and this can be hit if rate limits are encountered or if data extraction simply takes longer than that (e.g. large org, significant numbers of workflows, etc...).

This PR introduces logic that will attempt to refresh an existing session in the event that 401 errors are encountered during extraction (indicating the token has expired), or if the token is > 50 minutes old, hard-failing after a handful of attempts to do so.

This PR was heavily AI-assisted so review from someone with better knowledge of GitHound's auth flow than me should certainly give it a review. It should be fully backwards compatible, does not appear to introduce any breaking changes, and is (so far) working as expected in my own testing.

Example:

...
WARNING: Rate limit hit when doing Github RestAPI call. Retry 1/3
Reached rate limit. Sleeping for 2394 seconds. Tokens reset at unix time 1776796891
WARNING: Received 401 Unauthorized. Attempting token refresh...
Refreshing GitHub App installation token...
GitHub App installation token refreshed. New expiry: 04/21/2026 19:41:32 +00:00
...

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.

1 participant