inth-oauth2/examples/google-web.rs

30 lines
804 B
Rust
Raw Normal View History

2017-08-23 06:39:49 +00:00
extern crate reqwest;
2016-02-28 00:23:53 +00:00
extern crate inth_oauth2;
use std::io;
use inth_oauth2::Client;
use inth_oauth2::provider::google::Web;
fn main() {
2017-08-23 06:39:49 +00:00
let http_client = reqwest::Client::new().unwrap();
2017-06-05 00:05:30 +00:00
2017-08-23 18:09:05 +00:00
let client = Client::new(
Web,
2016-02-28 00:23:53 +00:00
String::from("143225766783-0h4h5ktpvhc7kqp6ohbpd2sssqrap57n.apps.googleusercontent.com"),
String::from("7Xjn-vRN-8qsz3Zh9zZGkHsM"),
Some(String::from("https://cmcenroe.me/oauth2-paste/")),
);
2017-08-23 06:39:49 +00:00
let auth_uri = client
.auth_uri(Some("https://www.googleapis.com/auth/userinfo.email"), None)
2016-02-28 00:23:53 +00:00
.unwrap();
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();
2016-02-28 00:23:53 +00:00
println!("{:?}", token);
}