Add google::Web example

This commit is contained in:
Curtis McEnroe 2016-02-27 19:23:53 -05:00
parent 6c885b5a1b
commit 7560582755
1 changed files with 24 additions and 0 deletions

24
examples/google-web.rs Normal file
View File

@ -0,0 +1,24 @@
extern crate inth_oauth2;
use std::io;
use inth_oauth2::Client;
use inth_oauth2::provider::google::Web;
fn main() {
let client = Client::<Web>::new(
String::from("143225766783-0h4h5ktpvhc7kqp6ohbpd2sssqrap57n.apps.googleusercontent.com"),
String::from("7Xjn-vRN-8qsz3Zh9zZGkHsM"),
Some(String::from("https://cmcenroe.me/oauth2-paste/")),
);
let auth_uri = client.auth_uri(Some("https://www.googleapis.com/auth/userinfo.email"), None)
.unwrap();
println!("{}", auth_uri);
let mut code = String::new();
io::stdin().read_line(&mut code).unwrap();
let token = client.request_token(&Default::default(), code.trim()).unwrap();
println!("{:?}", token);
}