mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-02-23 15:50:00 +01:00
Refactor JWT handling in ServiceAccountAccess.
Avoid reading and parsing the private key file on every invocation of token() in favor or reading it once when the ServiceAccountAccess is built. Also avoid unnecessary allocations when signing JWT tokens and renamed sub to subject to avoid any confusion with the std::ops::Sub trait.
This commit is contained in:
@@ -7,7 +7,9 @@ use yup_oauth2::GetToken;
|
||||
async fn main() {
|
||||
let creds =
|
||||
yup_oauth2::service_account_key_from_file(path::Path::new("serviceaccount.json")).unwrap();
|
||||
let sa = yup_oauth2::ServiceAccountAccess::new(creds).build();
|
||||
let sa = yup_oauth2::ServiceAccountAccess::new(creds)
|
||||
.build()
|
||||
.unwrap();
|
||||
let scopes = &["https://www.googleapis.com/auth/pubsub"];
|
||||
|
||||
let tok = sa.token(scopes).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user