Created
April 16, 2016 14:12
-
-
Save dermesser/8c915ec4c88ee8e8927e7d40b276ca52 to your computer and use it in GitHub Desktop.
Example for installed flow with yup-oauth2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn read_client_secret(file: &str) -> ApplicationSecret { | |
use std::fs::{File, OpenOptions}; | |
use std::io::Read; | |
let mut secret = String::new(); | |
OpenOptions::new().read(true).open(file).unwrap().read_to_string(&mut secret); | |
let consappsec: ConsoleApplicationSecret = serde_json::from_str(secret.as_str()).unwrap(); | |
consappsec.installed.unwrap() | |
} | |
fn main() { | |
let secret = read_client_secret("client_secret.json"); | |
let mut client = hyper::Client::new(); | |
let mut auth = | |
Authenticator::new(&secret, | |
DefaultAuthenticatorDelegate, | |
&mut client, | |
<MemoryStorage as Default>::default(), | |
Some(FlowType::InstalledInteractive)); // This is the main change! | |
let mut hub = Drive::new(hyper::Client::new(), auth); | |
match hub.files().list().q("'root' in parents and not trashed").doit() { | |
Ok(o) => println!("{:?}", o), | |
Err(e) => println!("{}", e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment