From be867917628d8c9cf09268bf13c97193dcd1a1dc Mon Sep 17 00:00:00 2001 From: James Hinshelwood Date: Wed, 15 Sep 2021 15:58:03 +0100 Subject: [PATCH] Add token deserialization workaround This fixes token deserialization when the serde_json/arbitrary_precision feature is enabled. See https://github.com/serde-rs/json/issues/559 for details. Co-authored-by: James Hinshelwood --- src/types.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types.rs b/src/types.rs index f29286f..0da033f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -75,12 +75,15 @@ impl TokenInfo { expires_in: Option, } + // Serialize first to a `serde_json::Value` then to `AuthErrorOr` to work around this bug in + // serde_json: https://github.com/serde-rs/json/issues/559 + let raw_token = serde_json::from_slice::(json_data)?; let RawToken { access_token, refresh_token, token_type, expires_in, - } = serde_json::from_slice::>(json_data)?.into_result()?; + } = >::deserialize(raw_token)?.into_result()?; if token_type.to_lowercase().as_str() != "bearer" { use std::io;