From 5627530f9caf94d9f8f32bdc75d0ca5dc2d1247d Mon Sep 17 00:00:00 2001 From: edelangh Date: Mon, 15 Oct 2018 23:54:36 +0200 Subject: [PATCH] update bearer documentation --- src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 09f20e0..3c16ac8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -103,6 +103,27 @@ //! # } //! ``` //! +//! ### Using bearer access tokens +//! +//! Bearer tokens can be converted to Hyper headers. +//! +//! ```no_run +//! # extern crate inth_oauth2; +//! # extern crate reqwest; +//! # use inth_oauth2::Client; +//! # use inth_oauth2::provider::google::Installed; +//! use inth_oauth2::Token; +//! +//! # fn main() { +//! # let oauth_client = Client::new(Installed, String::new(), String::new(), None); +//! # let http = reqwest::Client::new(); +//! # let token = oauth_client.request_token(&http, "").unwrap(); +//! let request = http.get("https://example.com/resource") +//! .bearer_auth(token.access_token()) +//! .build(); +//! # } +//! ``` +//! //! ### Persisting tokens //! //! All token types implement `Serialize` and `Deserialize` from `serde`.