From 9e31f1912f076cab03ccdfc3ef8c1bc072445746 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Wed, 23 Nov 2022 14:46:36 -0600 Subject: [PATCH] Expand example. --- examples/service_account_impersonation.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/service_account_impersonation.rs b/examples/service_account_impersonation.rs index b5841d9..b081444 100644 --- a/examples/service_account_impersonation.rs +++ b/examples/service_account_impersonation.rs @@ -12,6 +12,19 @@ async fn main() { .await .expect("user secret"); + let auth = ServiceAccountImpersonationAuthenticator::builder(user_secret.clone(), &svc_email) + .build() + .await + .expect("authenticator"); + + let scopes = &["https://www.googleapis.com/auth/youtube.readonly"]; + match auth.token(scopes).await { + Err(e) => println!("error: {:?}", e), + Ok(t) => println!("token: {:?}", t), + } + + // If you configure the authenticator to request id tokens, it will give back id tokens + // instead of access tokens. let auth = ServiceAccountImpersonationAuthenticator::builder(user_secret, &svc_email) .request_id_token() .build()