fix: only try to refresh access tokens if we have a refresh token or an expiry time (#594)

This commit is contained in:
David Stern 2026-01-05 20:34:42 -05:00 • committed by GitHub
commit 63d89b1a4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -612,6 +612,8 @@ impl AuthorizationManager {
let credentials = stored.and_then(|s| s.token_response); let credentials = stored.and_then(|s| s.token_response);
if let Some(creds) = credentials.as_ref() { if let Some(creds) = credentials.as_ref() {
// check token expiry if we have a refresh token or an expiry time
if creds.refresh_token().is_some() || creds.expires_in().is_some() {
let expires_in = creds.expires_in().unwrap_or(Duration::from_secs(0)); let expires_in = creds.expires_in().unwrap_or(Duration::from_secs(0));
if expires_in <= Duration::from_secs(0) { if expires_in <= Duration::from_secs(0) {
tracing::info!("Access token expired, refreshing."); tracing::info!("Access token expired, refreshing.");
@ -620,6 +622,7 @@ impl AuthorizationManager {
tracing::info!("Refreshed access token."); tracing::info!("Refreshed access token.");
return Ok(new_creds.access_token().secret().to_string()); return Ok(new_creds.access_token().secret().to_string());
} }
}
Ok(creds.access_token().secret().to_string()) Ok(creds.access_token().secret().to_string())
} else { } else {