matcha
matcha copied to clipboard
BUG: OAuth2 token expiry not validated before use
Describe the bug
In fetcher/fetcher.go lines 240-243, OAuth2 token fetched without expiration check:
token, err := config.GetOAuth2Token(account.Email)
if err != nil {
return nil, fmt.Errorf("oauth2: %w", err)
}
// Token used immediately without expiry check
If token expired, IMAP connection fails with unclear auth error instead of refreshing token.
To reproduce
- Configure OAuth2 for account
- Let token expire
- Start matcha
- Connection fails - "authentication failed" instead of auto-refresh
Expected behavior
Check expiry and refresh if needed:
token, err := config.GetOAuth2Token(account.Email)
if err != nil {
return nil, fmt.Errorf("oauth2: %w", err)
}
// Check if token expired
if !token.Valid() {
// Refresh token
newToken, err := refreshOAuth2Token(token)
if err != nil {
return nil, fmt.Errorf("oauth2 token refresh failed: %w", err)
}
token = newToken
// Save refreshed token
}
Screenshots
N/A
Additional context
- File:
fetcher/fetcher.go - Lines: 240-243
- Severity: Medium - failed connections with expired tokens
- Fix complexity: Medium - implement token refresh logic
This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.
Closing due to inactivity. Reopen if still relevant.