@@ -17,19 +17,16 @@ pub(crate) trait ServiceAccount: Send + Sync {
1717
1818/// Authentication manager is responsible for caching and obtaing credentials for the required scope
1919///
20- /// Cacheing for the full life time is ensured
20+ /// Construct the authentication manager with [`AuthenticationManager::new()`] or by creating
21+ /// a [`CustomServiceAccount`], then converting it into an `AuthenticationManager` using the `From`
22+ /// impl.
2123pub struct AuthenticationManager {
2224 pub ( crate ) client : HyperClient ,
2325 pub ( crate ) service_account : Box < dyn ServiceAccount > ,
2426 refresh_mutex : Mutex < ( ) > ,
2527}
2628
2729impl AuthenticationManager {
28- /// Create an `AuthenticationManager` directly from a custom service account
29- pub fn from_custom_service_account ( service_account : CustomServiceAccount ) -> Self {
30- Self :: build ( types:: client ( ) , service_account)
31- }
32-
3330 /// Finds a service account provider to get authentication tokens from
3431 ///
3532 /// Tries the following approaches, in order:
@@ -46,7 +43,7 @@ impl AuthenticationManager {
4643 pub async fn new ( ) -> Result < Self , Error > {
4744 tracing:: debug!( "Initializing gcp_auth" ) ;
4845 if let Some ( service_account) = CustomServiceAccount :: from_env ( ) ? {
49- return Ok ( Self :: from_custom_service_account ( service_account) ) ;
46+ return Ok ( service_account. into ( ) ) ;
5047 }
5148
5249 let client = types:: client ( ) ;
@@ -121,6 +118,6 @@ impl AuthenticationManager {
121118
122119impl From < CustomServiceAccount > for AuthenticationManager {
123120 fn from ( service_account : CustomServiceAccount ) -> Self {
124- Self :: from_custom_service_account ( service_account)
121+ Self :: build ( types :: client ( ) , service_account)
125122 }
126123}
0 commit comments