Skip to content

Commit a49941b

Browse files
author
Floris Bruynooghe
committed
Add debug logging to indicate which mechanism was selected
1 parent b352eb0 commit a49941b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,40 @@ async fn get_authentication_manager(
105105
let custom = match credential_path {
106106
Some(path) => CustomServiceAccount::from_file(path).await,
107107
None => match std::env::var("GOOGLE_APPLICATION_CREDENTIALS") {
108-
Ok(path) => CustomServiceAccount::from_file(Path::new(&path)).await,
108+
Ok(path) => {
109+
log::debug!("Trying GOOGLE_APPLICATION_CREDENTIALS env var");
110+
CustomServiceAccount::from_file(Path::new(&path)).await
111+
}
109112
Err(_) => Err(Error::ApplicationProfileMissing),
110113
},
111114
};
112115

113116
if let Ok(service_account) = custom {
117+
log::debug!("Using CustomServiceAccount");
114118
return Ok(AuthenticationManager::new(
115119
client,
116120
Box::new(service_account),
117121
));
118122
}
119123
let gcloud = gcloud_authorized_user::GCloudAuthorizedUser::new().await;
120124
if let Ok(service_account) = gcloud {
125+
log::debug!("Using GCloudAuthorizedUser");
121126
return Ok(AuthenticationManager::new(
122127
client.clone(),
123128
Box::new(service_account),
124129
));
125130
}
126131
let default = default_service_account::DefaultServiceAccount::new(&client).await;
127132
if let Ok(service_account) = default {
133+
log::debug!("Using DefaultServiceAccount");
128134
return Ok(AuthenticationManager::new(
129135
client.clone(),
130136
Box::new(service_account),
131137
));
132138
}
133139
let user = default_authorized_user::DefaultAuthorizedUser::new(&client).await;
134140
if let Ok(user_account) = user {
141+
log::debug!("Using DefaultAuthorizedUser");
135142
return Ok(AuthenticationManager::new(client, Box::new(user_account)));
136143
}
137144
Err(Error::NoAuthMethod(
@@ -145,5 +152,6 @@ async fn get_authentication_manager(
145152
///
146153
/// Returns `AuthenticationManager` which can be used to obtain tokens
147154
pub async fn init() -> Result<AuthenticationManager, Error> {
155+
log::debug!("Initializing gcp_auth");
148156
get_authentication_manager(None).await
149157
}

0 commit comments

Comments
 (0)