Google Cloud Platform server application authentication library.
[dependencies]
google-cloud-auth = 0.1.0
```rust use googlecloudauth::*;
async fn main() -> Result<(), error::Error> {
let audience = "https://spanner.googleapis.com/";
let scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/spanner.data",
];
let config = Config {
// audience is required only for service account jwt-auth
// https://developers.google.com/identity/protocols/oauth2/service-account#jwt-auth
audience: Some(audience),
// scopes is required only for service account Oauth2
// https://developers.google.com/identity/protocols/oauth2/service-account
scopes: Some(&scopes)
};
let ts = createtokensource(config).await?;
let token = ts.token().await?;
println!("token is {}",token.access_token);
Ok(())
}
```
create_token_source
looks for credentials in the following places,
preferring the first location found:
https://cloud.google.com/iam/docs/workload-identity-federation