google_installed/
google-installed.rs

1extern crate reqwest;
2extern crate inth_oauth2;
3
4use std::io;
5
6use inth_oauth2::Client;
7use inth_oauth2::provider::google::{Installed, REDIRECT_URI_OOB};
8
9fn main() {
10    let http_client = reqwest::Client::new();
11
12    let client = Client::new(
13        Installed,
14        String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"),
15        String::from("3kZ5WomzHFlN2f_XbhkyPd3o"),
16        Some(String::from(REDIRECT_URI_OOB)),
17    );
18
19    let auth_uri = client.auth_uri(Some("https://www.googleapis.com/auth/userinfo.email"), None);
20    println!("{}", auth_uri);
21
22    let mut code = String::new();
23    io::stdin().read_line(&mut code).unwrap();
24
25    let token = client.request_token(&http_client, code.trim()).unwrap();
26    println!("{:?}", token);
27
28    let token = client.refresh_token(&http_client, token, None).unwrap();
29    println!("{:?}", token);
30}