pub async fn provider() -> Result<Arc<dyn TokenProvider>, Error>
Expand description
Finds a service account provider to get authentication tokens from
Tries the following approaches, in order:
- Check if the
GOOGLE_APPLICATION_CREDENTIALS
environment variable if set; if so, use a custom service account as the token source. - Look for credentials in
.config/gcloud/application_default_credentials.json
; if found, use these credentials to request refresh tokens. - Send a HTTP request to the internal metadata server to retrieve a token; if it succeeds, use the default service account as the token source.
- Check if the
gcloud
tool is available on thePATH
; if so, use thegcloud auth print-access-token
command as the token source.