diff --git a/google-apis-common/src/serde.rs b/google-apis-common/src/serde.rs index 622a60a215..84be4a2a28 100644 --- a/google-apis-common/src/serde.rs +++ b/google-apis-common/src/serde.rs @@ -170,7 +170,13 @@ pub mod standard_base64 { D: Deserializer<'de>, { let s: Cow = Deserialize::deserialize(deserializer)?; - base64::prelude::BASE64_STANDARD.decode(s.as_ref()).map_err(serde::de::Error::custom) + match base64::prelude::BASE64_STANDARD.decode(s.as_ref()) { + Ok(decoded) => Ok(decoded), + Err(first_err) => match general_purpose::URL_SAFE.decode(s.as_ref()) { + Ok(decoded) => Ok(decoded), + Err(_) => Err(serde::de::Error::custom(first_err)) + } + } } } } @@ -202,7 +208,13 @@ pub mod urlsafe_base64 { D: Deserializer<'de>, { let s: Cow = Deserialize::deserialize(deserializer)?; - base64::prelude::BASE64_URL_SAFE.decode(s.as_ref()).map_err(serde::de::Error::custom) + match base64::prelude::URL_SAFE.decode(s.as_ref()) { + Ok(decoded) => Ok(decoded), + Err(first_err) => match general_purpose::URL_STANDARD.decode(s.as_ref()) { + Ok(decoded) => Ok(decoded), + Err(_) => Err(serde::de::Error::custom(first_err)) + } + } } } }