mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-07 19:47:03 +01:00
22 lines
678 B
Rust
22 lines
678 B
Rust
use yup_oauth2::{InstalledFlowAuthenticator, InstalledFlowReturnMethod};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let app_secret = yup_oauth2::read_application_secret("clientsecret.json")
|
|
.await
|
|
.expect("clientsecret.json");
|
|
|
|
let auth =
|
|
InstalledFlowAuthenticator::builder(app_secret, InstalledFlowReturnMethod::HTTPRedirect)
|
|
.persist_tokens_to_disk("tokencache.json")
|
|
.build()
|
|
.await
|
|
.unwrap();
|
|
let scopes = &["https://www.googleapis.com/auth/drive.file"];
|
|
|
|
match auth.token(scopes).await {
|
|
Err(e) => println!("error: {:?}", e),
|
|
Ok(t) => println!("The token is {:?}", t),
|
|
}
|
|
}
|