diff --git a/src/mako/api/api.rs.mako b/src/mako/api/api.rs.mako index d735276985..e7a37ea3da 100644 --- a/src/mako/api/api.rs.mako +++ b/src/mako/api/api.rs.mako @@ -50,7 +50,7 @@ ${lib.hub_usage_example(c)}\ pub struct ${hub_type}${ht_params} { client: RefCell, - auth: RefCell>>, + auth: oauth2::authenticator::Authenticator>, _user_agent: String, _base_url: String, _root_url: String, @@ -64,7 +64,7 @@ impl<'a, ${', '.join(HUB_TYPE_PARAMETERS)}> ${hub_type}${ht_params} pub fn new(client: C, authenticator: oauth2::authenticator::Authenticator>) -> ${hub_type}${ht_params} { ${hub_type} { client: RefCell::new(client), - auth: RefCell::new(authenticator), + auth: authenticator, _user_agent: "${default_user_agent}".to_string(), _base_url: "${baseUrl}".to_string(), _root_url: "${rootUrl}".to_string(), diff --git a/src/mako/api/lib/mbuild.mako b/src/mako/api/lib/mbuild.mako index 887065b6df..7415ccb4a8 100644 --- a/src/mako/api/lib/mbuild.mako +++ b/src/mako/api/lib/mbuild.mako @@ -451,7 +451,7 @@ match result { delegate = 'self.' + property(DELEGATE_PROPERTY_NAME) delegate_finish = 'dlg.finished' - auth_call = 'self.hub.auth.borrow_mut()' + auth_call = 'self.hub.auth' default_scope = method_default_scope(m) @@ -700,8 +700,7 @@ else { loop { % if default_scope: - let authenticator = ${auth_call}; - let token = match authenticator.token(&self.${api.properties.scopes}.keys().collect::>()[..]).await { + let token = match ${auth_call}.token(&self.${api.properties.scopes}.keys().collect::>()[..]).await { Ok(token) => token.clone(), Err(err) => { match dlg.token(&err) { @@ -841,12 +840,11 @@ else { dlg.store_upload_url(Some(url_str)); } - drop(authenticator); client::ResumableUploadHelper { client: &mut client.borrow_mut(), delegate: dlg, start_at: if upload_url_from_server { Some(0) } else { None }, - auth: &mut *${auth_call}, + auth: &${auth_call}, user_agent: &self.hub._user_agent, auth_header: format!("Bearer {}", token.as_str()), url: url_str, diff --git a/src/rust/api/client.rs b/src/rust/api/client.rs index e1ad6cf5c0..84d05dfda6 100644 --- a/src/rust/api/client.rs +++ b/src/rust/api/client.rs @@ -613,7 +613,7 @@ pub struct ResumableUploadHelper<'a, A: 'a> { >, pub delegate: &'a mut dyn Delegate, pub start_at: Option, - pub auth: &'a mut A, + pub auth: &'a A, pub user_agent: &'a str, pub auth_header: String, pub url: &'a str,