Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/perms/oauth.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
//! Service responsible for authenticating with the cache with Oauth tokens.
//! This authenticator periodically fetches a new token every set amount of seconds.
use crate::{
deps::tracing::{error, info},
utils::from_env::FromEnv,
};
use core::fmt;
use crate::{deps::tracing::error, utils::from_env::FromEnv};
use core::{error::Error, fmt};
use oauth2::{
basic::{BasicClient, BasicTokenType},
AccessToken, AuthUrl, ClientId, ClientSecret, EmptyExtraTokenFields, EndpointNotSet,
Expand All @@ -16,7 +13,7 @@ use tokio::{
sync::watch::{self, Ref},
task::JoinHandle,
};
use tracing::Instrument;
use tracing::{debug, Instrument};

type Token = StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>;

Expand Down Expand Up @@ -165,13 +162,14 @@ impl Authenticator {
let interval = self.config.oauth_token_refresh_interval;

loop {
info!("Refreshing oauth token");
debug!("Refreshing oauth token");
match self.authenticate().await {
Ok(_) => {
info!("Successfully refreshed oauth token");
debug!("Successfully refreshed oauth token");
}
Err(e) => {
error!(%e, "Failed to refresh oauth token");
Err(err) => {
let err_source = err.source().map(|e| e.to_string());
error!(%err, err_source, "Failed to refresh oauth token");
}
};
let _sleep = tokio::time::sleep(tokio::time::Duration::from_secs(interval)).await;
Expand Down