inth-oauth2/examples/imgur.rs

31 lines
777 B
Rust
Raw Normal View History

2017-08-23 06:39:49 +00:00
extern crate reqwest;
2015-12-22 04:36:04 +00:00
extern crate inth_oauth2;
use std::io;
2015-12-26 01:23:48 +00:00
use inth_oauth2::Client;
2015-12-22 04:36:04 +00:00
use inth_oauth2::provider::Imgur;
fn main() {
2017-10-14 17:56:07 +00:00
let http_client = reqwest::Client::new();
2017-06-05 00:05:30 +00:00
2017-08-23 18:09:05 +00:00
let client = Client::new(
Imgur,
2016-01-29 02:54:14 +00:00
String::from("505c8ca804230e0"),
String::from("c898d8cf28404102752b2119a3a1c6aab49899c8"),
2017-08-23 06:39:49 +00:00
Some(String::from("https://cmcenroe.me/oauth2-paste/")),
2015-12-22 04:36:04 +00:00
);
2017-09-26 18:37:21 +00:00
let auth_uri = client.auth_uri(None, None);
2015-12-22 04:36:04 +00:00
println!("{}", auth_uri);
let mut code = String::new();
io::stdin().read_line(&mut code).unwrap();
2017-08-23 06:39:49 +00:00
let token = client.request_token(&http_client, code.trim()).unwrap();
println!("{:?}", token);
2017-08-23 06:39:49 +00:00
let token = client.refresh_token(&http_client, token, None).unwrap();
println!("{:?}", token);
2015-12-22 04:36:04 +00:00
}