Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyper 1.0 #216

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ service_account = ["hyper-rustls", "rustls", "rustls-pemfile"]
[dependencies]
anyhow = "1.0.38"
async-trait = "^0.1"
base64 = "0.21"
base64 = "0.22"
futures = "0.3"
http = "0.2"
hyper = { version = "0.14", features = ["client", "server", "tcp", "http2"] }
hyper-rustls = { version = "0.25", optional = true, features = ["http2"] }
hyper-tls = { version = "0.5.0", optional = true }
http = "1"
http-body-util = "0.1"
hyper = { version = "1", features = ["http2"] }
hyper-util = "0.1"
hyper-rustls = { version = "0.27", optional = true, default-features = false, features = ["http2"] }
hyper-tls = { version = "0.6.0", optional = true }
itertools = "0.12"
log = "0.4"
percent-encoding = "2"
rustls = { version = "^0.22.1", optional = true }
rustls = { version = "^0.23", optional = true, features = ["ring"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally there'd be a feature to let user decide between aws-lc-rs & ring, but current code relies on ring

rustls-pemfile = { version = "1.0.1", optional = true }
seahash = "4"
serde = {version = "1.0", features = ["derive"]}
Expand All @@ -53,11 +55,11 @@ tower-service = "^0.3.1"
url = "2"

[dev-dependencies]
httptest = "0.15"
env_logger = "0.10"
httptest = "0.16"
env_logger = "0.11"
tempfile = "3.1"
webbrowser = "0.8"
hyper-rustls = "0.25"
webbrowser = "1"
hyper-rustls = "0.27"

[workspace]
members = ["examples/test-installed/", "examples/test-svc-acct/", "examples/test-device/", "examples/test-adc"]
Expand Down
6 changes: 3 additions & 3 deletions examples/custom_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use std::error::Error as StdError;

use http::Uri;
use hyper::client::connect::Connection;
use hyper_util::client::legacy::connect::Connection;
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service;

async fn r#use<S>(
client: hyper::Client<S>,
client: hyper_util::client::legacy::Client<S, String>,
authenticator: yup_oauth2::authenticator::Authenticator<S>,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>>
where
Expand Down Expand Up @@ -41,7 +41,7 @@ async fn main() {
let secret = yup_oauth2::read_service_account_key(google_credentials)
.await
.expect("$GOOGLE_APPLICATION_CREDENTIALS is not a valid service account key");
let client = hyper::Client::builder().build(
let client = hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new()).build(
hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("failed to find native root certificates")
Expand Down
4 changes: 2 additions & 2 deletions src/access_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use crate::error::Error;
use crate::types::TokenInfo;
use http::Uri;
use hyper::client::connect::Connection;
use hyper_util::client::legacy::connect::Connection;
use std::error::Error as StdError;
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service;
Expand All @@ -22,7 +22,7 @@ impl AccessTokenFlow {
/// just return the access token
pub(crate) async fn token<S, T>(
&self,
_hyper_client: &hyper::Client<S>,
_hyper_client: &hyper_util::client::legacy::Client<S, String>,
_scopes: &[T],
) -> Result<TokenInfo, Error>
where
Expand Down
15 changes: 8 additions & 7 deletions src/application_default_credentials.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::error::Error;
use crate::types::TokenInfo;
use http::Uri;
use hyper::client::connect::Connection;
use http_body_util::BodyExt;
use hyper_util::client::legacy::connect::{Connect, Connection};
use std::error::Error as StdError;
use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service;
Expand All @@ -25,25 +26,25 @@ impl ApplicationDefaultCredentialsFlow {

pub(crate) async fn token<S, T>(
&self,
hyper_client: &hyper::Client<S>,
hyper_client: &hyper_util::client::legacy::Client<S, String>,
scopes: &[T],
) -> Result<TokenInfo, Error>
where
T: AsRef<str>,
S: Service<Uri> + Clone + Send + Sync + 'static,
S: Service<Uri> + Connect + Clone + Send + Sync + 'static,
S::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
S::Error: Into<Box<dyn StdError + Send + Sync>>
{
let scope = crate::helper::join(scopes, ",");
let token_uri = format!("{}?scopes={}", self.metadata_url, scope);
let request = hyper::Request::get(token_uri)
.header("Metadata-Flavor", "Google")
.body(hyper::Body::from(String::new())) // why body is needed?
.body(String::new())
.unwrap();
log::debug!("requesting token from metadata server: {:?}", request);
let (head, body) = hyper_client.request(request).await?.into_parts();
let body = hyper::body::to_bytes(body).await?;
let (head, body) = hyper_client.request(request).await.map_err(|err| Error::OtherError(err.into()))?.into_parts();
let body = body.collect().await?.to_bytes();
log::debug!("received response; head: {:?}, body: {:?}", head, body);
TokenInfo::from_json(&body)
}
Expand Down
50 changes: 25 additions & 25 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use futures::lock::Mutex;
use http::Uri;
use hyper::client::connect::Connection;
use hyper_util::client::legacy::connect::Connection;
use std::borrow::Cow;
use std::error::Error as StdError;
use std::fmt;
Expand All @@ -32,7 +32,7 @@
use tower_service::Service;

struct InnerAuthenticator<S> {
hyper_client: hyper::Client<S>,
hyper_client: hyper_util::client::legacy::Client<S, String>,
storage: Storage,
auth_flow: AuthFlow,
}
Expand Down Expand Up @@ -136,7 +136,7 @@
) => {
// token is expired but has a refresh token.
let token_info_result = RefreshFlow::refresh_token(
&self.inner.hyper_client,

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 139 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied
app_secret,
&refresh_token,
)
Expand All @@ -147,7 +147,7 @@
// token refresh failed.
self.inner
.auth_flow
.token(&self.inner.hyper_client, scopes)

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 150 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied
.await?
};
self.inner
Expand All @@ -161,7 +161,7 @@
let token_info = self
.inner
.auth_flow
.token(&self.inner.hyper_client, scopes)

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-rustls,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Read` is not satisfied

Check failure on line 164 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (service_account,hyper-tls)

the trait bound `<S as tower_service::Service<Uri>>::Response: hyper::rt::Write` is not satisfied
.await?;
self.inner
.storage
Expand Down Expand Up @@ -544,7 +544,7 @@
/// ```
/// # #[cfg(any(feature = "hyper-rustls", feature = "hyper-tls"))]
/// # async fn foo() {
/// # let custom_hyper_client = hyper::Client::new();
/// # let custom_hyper_client = hyper_util::client::legacy::Client::new();
/// # let app_secret = yup_oauth2::read_application_secret("/tmp/foo").await.unwrap();
/// let authenticator = yup_oauth2::DeviceFlowAuthenticator::builder(app_secret)
/// .hyper_client(custom_hyper_client)
Expand Down Expand Up @@ -604,10 +604,10 @@
}

/// Use the provided hyper client.
pub fn hyper_client<NewC>(
pub fn hyper_client<NewC, B: hyper::body::Body>(
self,
hyper_client: hyper::Client<NewC>,
) -> AuthenticatorBuilder<hyper::Client<NewC>, F> {
hyper_client: hyper_util::client::legacy::Client<NewC, B>,
) -> AuthenticatorBuilder<hyper_util::client::legacy::Client<NewC, B>, F> {
AuthenticatorBuilder {
hyper_client_builder: hyper_client,
storage_type: self.storage_type,
Expand Down Expand Up @@ -914,12 +914,12 @@

pub(crate) async fn token<'a, S, T>(
&'a self,
hyper_client: &'a hyper::Client<S>,
hyper_client: &'a hyper_util::client::legacy::Client<S, String>,
scopes: &'a [T],
) -> Result<TokenInfo, Error>
where
T: AsRef<str>,
S: Service<Uri> + Clone + Send + Sync + 'static,
S: Service<Uri> + hyper_util::client::legacy::connect::Connect + Clone + Send + Sync + 'static,
S::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Expand Down Expand Up @@ -955,17 +955,17 @@
}
}

/// A trait implemented for any hyper::Client as well as the DefaultHyperClient.
/// A trait implemented for any hyper_util::client::legacy::Client as well as the DefaultHyperClient.
pub trait HyperClientBuilder {
/// The hyper connector that the resulting hyper client will use.
type Connector: Service<Uri> + Clone + Send + Sync + 'static;

/// Create a hyper::Client
fn build_hyper_client(self) -> Result<hyper::Client<Self::Connector>, Error>;
/// Create a hyper_util::client::legacy::Client
fn build_hyper_client(self) -> Result<hyper_util::client::legacy::Client<Self::Connector, String>, Error>;

/// Create a `hyper::Client` for tests (HTTPS not required)
/// Create a `hyper_util::client::legacy::Client` for tests (HTTPS not required)
#[doc(hidden)]
fn build_test_hyper_client(self) -> hyper::Client<Self::Connector>;
fn build_test_hyper_client(self) -> hyper_util::client::legacy::Client<Self::Connector, String>;
}

#[cfg(feature = "hyper-rustls")]
Expand All @@ -975,7 +975,7 @@
)]
/// Default authenticator type
pub type DefaultAuthenticator =
Authenticator<hyper_rustls::HttpsConnector<hyper::client::HttpConnector>>;
Authenticator<hyper_rustls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>>;

#[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))]
#[cfg_attr(
Expand All @@ -984,7 +984,7 @@
)]
/// Default authenticator type
pub type DefaultAuthenticator =
Authenticator<hyper_tls::HttpsConnector<hyper::client::HttpConnector>>;

Check failure on line 987 in src/authenticator.rs

View workflow job for this annotation

GitHub Actions / yup-oauth2 (hyper-tls)

cannot find type `HttpConnector` in module `hyper::client`

/// The builder value used when the default hyper client should be used.
#[cfg(any(feature = "hyper-rustls", feature = "hyper-tls"))]
Expand All @@ -1001,11 +1001,11 @@
)]
impl HyperClientBuilder for DefaultHyperClient {
#[cfg(feature = "hyper-rustls")]
type Connector = hyper_rustls::HttpsConnector<hyper::client::connect::HttpConnector>;
type Connector = hyper_rustls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>;
#[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))]
type Connector = hyper_tls::HttpsConnector<hyper::client::connect::HttpConnector>;
type Connector = hyper_tls::HttpsConnector<hyper_util::client::legacy::connect::HttpConnector>;

fn build_hyper_client(self) -> Result<hyper::Client<Self::Connector>, Error> {
fn build_hyper_client(self) -> Result<hyper_util::client::legacy::Client<Self::Connector, String>, Error> {
#[cfg(feature = "hyper-rustls")]
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()?
Expand All @@ -1016,12 +1016,12 @@
#[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))]
let connector = hyper_tls::HttpsConnector::new();

Ok(hyper::Client::builder()
Ok(hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new())
.pool_max_idle_per_host(0)
.build::<_, hyper::Body>(connector))
.build::<_, _>(connector))
}

fn build_test_hyper_client(self) -> hyper::Client<Self::Connector> {
fn build_test_hyper_client(self) -> hyper_util::client::legacy::Client<Self::Connector, String> {
#[cfg(feature = "hyper-rustls")]
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
Expand All @@ -1033,13 +1033,13 @@
#[cfg(all(not(feature = "hyper-rustls"), feature = "hyper-tls"))]
let connector = hyper_tls::HttpsConnector::new();

hyper::Client::builder()
hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new())
.pool_max_idle_per_host(0)
.build::<_, hyper::Body>(connector)
.build::<_, _>(connector)
}
}

impl<S> HyperClientBuilder for hyper::Client<S>
impl<S> HyperClientBuilder for hyper_util::client::legacy::Client<S, String>
where
S: Service<Uri> + Clone + Send + Sync + 'static,
S::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
Expand All @@ -1048,11 +1048,11 @@
{
type Connector = S;

fn build_hyper_client(self) -> Result<hyper::Client<S>, Error> {
fn build_hyper_client(self) -> Result<hyper_util::client::legacy::Client<S, String>, Error> {
Ok(self)
}

fn build_test_hyper_client(self) -> hyper::Client<Self::Connector> {
fn build_test_hyper_client(self) -> hyper_util::client::legacy::Client<Self::Connector, String> {
self
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/authorized_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use crate::error::Error;
use crate::types::TokenInfo;
use http::Uri;
use hyper::client::connect::Connection;
use http_body_util::BodyExt;
use hyper_util::client::legacy::connect::{Connect, Connection};
use hyper::header;
use serde::{Deserialize, Serialize};
use std::error::Error as StdError;
Expand Down Expand Up @@ -44,12 +45,12 @@ impl AuthorizedUserFlow {
/// Send a request for a new Bearer token to the OAuth provider.
pub(crate) async fn token<S, T>(
&self,
hyper_client: &hyper::Client<S>,
hyper_client: &hyper_util::client::legacy::Client<S, String>,
_scopes: &[T],
) -> Result<TokenInfo, Error>
where
T: AsRef<str>,
S: Service<Uri> + Clone + Send + Sync + 'static,
S: Service<Uri> + Connect + Clone + Send + Sync + 'static,
S::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
S::Future: Send + Unpin + 'static,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
Expand All @@ -65,12 +66,12 @@ impl AuthorizedUserFlow {

let request = hyper::Request::post(TOKEN_URI)
.header(header::CONTENT_TYPE, "application/x-www-form-urlencoded")
.body(hyper::Body::from(req))
.body(req)
.unwrap();

log::debug!("requesting token from authorized user: {:?}", request);
let (head, body) = hyper_client.request(request).await?.into_parts();
let body = hyper::body::to_bytes(body).await?;
let (head, body) = hyper_client.request(request).await.map_err(|err| Error::OtherError(err.into()))?.into_parts();
let body = body.collect().await?.to_bytes();
log::debug!("received response; head: {:?}, body: {:?}", head, body);
TokenInfo::from_json(&body)
}
Expand Down
Loading
Loading