Add imgur support
This commit is contained in:
parent
7bdf0a7657
commit
21facd2354
|
@ -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);
|
||||
}
|
|
@ -135,6 +135,12 @@ impl Client {
|
|||
github => (
|
||||
"https://github.com/login/oauth/authorize",
|
||||
"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"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,14 @@
|
|||
//! 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
|
||||
//!
|
||||
//! An authorization URI and a token URI are required.
|
||||
|
|
Loading…
Reference in New Issue