Add imgur support

This commit is contained in:
Curtis McEnroe 2015-12-01 19:10:33 -05:00
parent 7bdf0a7657
commit 21facd2354
3 changed files with 38 additions and 0 deletions

24
examples/imgur.rs Normal file
View File

@ -0,0 +1,24 @@
extern crate inth_oauth2;
use std::io;
use inth_oauth2::Client;
fn main() {
let client = Client::imgur(
Default::default(),
"505c8ca804230e0",
"c898d8cf28404102752b2119a3a1c6aab49899c8",
Some("https://cmcenroe.me/oauth2-paste/")
);
let auth_uri = client.auth_uri(None, None).unwrap();
println!("{}", auth_uri);
let mut code = String::new();
io::stdin().read_line(&mut code).unwrap();
let token_pair = client.request_token(code.trim()).unwrap();
println!("{:?}", token_pair);
}

View File

@ -135,6 +135,12 @@ impl Client {
github => ( github => (
"https://github.com/login/oauth/authorize", "https://github.com/login/oauth/authorize",
"https://github.com/login/oauth/access_token" "https://github.com/login/oauth/access_token"
),
#[doc = "Creates an Imgur OAuth 2.0 client.\n\n See [OAuth 2.0, Imgur](https://api.imgur.com/oauth2)."]
imgur => (
"https://api.imgur.com/oauth2/authorize",
"https://api.imgur.com/oauth2/token"
) )
} }
} }

View File

@ -35,6 +35,14 @@
//! let auth = OAuth2::github(Default::default(), "CLIENT_ID", "CLIENT_SECRET", None); //! let auth = OAuth2::github(Default::default(), "CLIENT_ID", "CLIENT_SECRET", None);
//! ``` //! ```
//! //!
//! ### Imgur
//!
//! ```
//! use inth_oauth2::Client as OAuth2;
//!
//! let auth = OAuth2::imgur(Default::default(), "CLIENT_ID", "CLIENT_SECRET", None);
//! ```
//!
//! ### Other //! ### Other
//! //!
//! An authorization URI and a token URI are required. //! An authorization URI and a token URI are required.