mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2025-12-31 16:40:05 +01:00
chore(syntax): Run rustfmt on examples.
This commit is contained in:
@@ -11,9 +11,11 @@ use std::path::Path;
|
||||
use hyper::net::HttpsConnector;
|
||||
use hyper_native_tls::NativeTlsClient;
|
||||
|
||||
use yup_oauth2::{Authenticator, FlowType, ApplicationSecret, DiskTokenStorage,
|
||||
DefaultAuthenticatorDelegate, read_application_secret};
|
||||
use google_drive3::Drive;
|
||||
use yup_oauth2::{
|
||||
read_application_secret, ApplicationSecret, Authenticator, DefaultAuthenticatorDelegate,
|
||||
DiskTokenStorage, FlowType,
|
||||
};
|
||||
|
||||
const CLIENT_SECRET_FILE: &'static str = "example_client_secret.json";
|
||||
|
||||
@@ -24,23 +26,31 @@ fn read_client_secret(file: String) -> ApplicationSecret {
|
||||
|
||||
fn main() {
|
||||
let secret = read_client_secret(CLIENT_SECRET_FILE.to_string());
|
||||
let client = hyper::Client::with_connector(
|
||||
HttpsConnector::new(NativeTlsClient::new().unwrap()));
|
||||
let authenticator = Authenticator::new(&secret,
|
||||
DefaultAuthenticatorDelegate,
|
||||
client,
|
||||
DiskTokenStorage::new(&"token_store.json".to_string())
|
||||
.unwrap(),
|
||||
Some(FlowType::InstalledInteractive));
|
||||
let client = hyper::Client::with_connector(
|
||||
HttpsConnector::new(NativeTlsClient::new().unwrap()));
|
||||
let client =
|
||||
hyper::Client::with_connector(HttpsConnector::new(NativeTlsClient::new().unwrap()));
|
||||
let authenticator = Authenticator::new(
|
||||
&secret,
|
||||
DefaultAuthenticatorDelegate,
|
||||
client,
|
||||
DiskTokenStorage::new(&"token_store.json".to_string()).unwrap(),
|
||||
Some(FlowType::InstalledInteractive),
|
||||
);
|
||||
let client =
|
||||
hyper::Client::with_connector(HttpsConnector::new(NativeTlsClient::new().unwrap()));
|
||||
let hub = Drive::new(client, authenticator);
|
||||
|
||||
let (_resp, list_result) = hub.files().list().q("'root' in parents and trashed = false").doit().unwrap();
|
||||
let (_resp, list_result) = hub
|
||||
.files()
|
||||
.list()
|
||||
.q("'root' in parents and trashed = false")
|
||||
.doit()
|
||||
.unwrap();
|
||||
|
||||
for file in list_result.files.unwrap_or(vec![]) {
|
||||
println!("{} ({})",
|
||||
file.name.unwrap_or(String::new()),
|
||||
file.mime_type.unwrap_or(String::new()));
|
||||
println!(
|
||||
"{} ({})",
|
||||
file.name.unwrap_or(String::new()),
|
||||
file.mime_type.unwrap_or(String::new())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user