diff --git a/google-apis-common/Cargo.toml b/google-apis-common/Cargo.toml index e66cf39c19..aa601650a3 100644 --- a/google-apis-common/Cargo.toml +++ b/google-apis-common/Cargo.toml @@ -24,11 +24,9 @@ serde_json = "^ 1.0" base64 = "0.13.0" chrono = { version = "0.4.22", features = ["serde"] } -## TODO: Make yup-oauth2 optional -## yup-oauth2 = { version = "^ 7.0", optional = true } -yup-oauth2 = "^ 7.0" +yup-oauth2 = { version = "^ 7.0", optional = true } itertools = "^ 0.10" -hyper = "^ 0.14" +hyper = { version = "^ 0.14", features = ["client", "http2"] } http = "^0.2" -tokio = "^1.0" +tokio = { version = "^1.0", features = ["time"] } tower-service = "^0.3.1" diff --git a/google-apis-common/src/auth.rs b/google-apis-common/src/auth.rs index 2f2cc9630a..6b9321fb06 100644 --- a/google-apis-common/src/auth.rs +++ b/google-apis-common/src/auth.rs @@ -71,7 +71,6 @@ use std::future::Future; use std::pin::Pin; -// TODO: Simplify this to Option type TokenResult = Option; pub trait GetToken: GetTokenClone + Send + Sync { @@ -121,8 +120,7 @@ pub struct NoToken; impl GetToken for NoToken {} -// TODO: Make this optional -// #[cfg(feature = "yup-oauth2")] +#[cfg(feature = "yup-oauth2")] mod yup_oauth2_impl { use core::future::Future; use core::pin::Pin; diff --git a/google-apis-common/src/lib.rs b/google-apis-common/src/lib.rs index 10aadd36b7..758cc0e09c 100644 --- a/google-apis-common/src/lib.rs +++ b/google-apis-common/src/lib.rs @@ -29,6 +29,7 @@ pub use auth::{GetToken, NoToken}; pub use chrono; pub use field_mask::FieldMask; pub use serde_with; +#[cfg(feature = "yup-oauth2")] pub use yup_oauth2 as oauth2; const LINE_ENDING: &str = "\r\n"; diff --git a/src/generator/templates/Cargo.toml.mako b/src/generator/templates/Cargo.toml.mako index d696b97f8a..3001397c39 100644 --- a/src/generator/templates/Cargo.toml.mako +++ b/src/generator/templates/Cargo.toml.mako @@ -58,6 +58,8 @@ path = "../${api_name}" version = "${util.crate_version()}" % endif -## TODO: Make yup-oauth2 optional -# [features] -# default = ["yup-oauth2"] +% if not cargo.get("is_executable", False): +[features] +yup-oauth2 = ["google-apis-common/yup-oauth2"] +default = ["yup-oauth2"] +% endif \ No newline at end of file diff --git a/src/generator/templates/api/api.rs.mako b/src/generator/templates/api/api.rs.mako index 9f58e0cdee..7029c36241 100644 --- a/src/generator/templates/api/api.rs.mako +++ b/src/generator/templates/api/api.rs.mako @@ -31,7 +31,7 @@ use tokio::time::sleep; use tower_service; use serde::{Serialize, Deserialize}; -use crate::{client, client::GetToken, client::oauth2, client::serde_with}; +use crate::{client, client::GetToken, client::serde_with}; // ############## // UTILITIES ### diff --git a/src/generator/templates/api/lib.rs.mako b/src/generator/templates/api/lib.rs.mako index f1042232ef..3aced87c47 100644 --- a/src/generator/templates/api/lib.rs.mako +++ b/src/generator/templates/api/lib.rs.mako @@ -49,5 +49,8 @@ pub mod api; // Re-export the hub type and some basic client structs pub use api::${hub_type}; +pub use client::{Result, Error, Delegate, FieldMask}; + // Re-export the yup_oauth2 crate, that is required to call some methods of the hub and the client -pub use client::{Result, Error, Delegate, oauth2, FieldMask}; +#[cfg(feature = "yup-oauth2")] +pub use client::oauth2; \ No newline at end of file