pub async fn get_credentials(
explicit_token: Option<&str>,
) -> Result<String, AuthError>Expand description
Retrieves an OAuth2 access token for Google Cloud Artifact Registry.
Credential resolution order:
explicit_token(used unchanged if valid).- Google Application Default Credentials (ADC) via service account file or user ADC.
- Fallback to
gcloud auth print-access-tokenCLI command.
§Arguments
explicit_token- Optional override token passed by the user.
§Errors
Returns AuthError::CredentialsUnavailable if both credential providers fail, or
AuthError::Config if an explicit token is invalid.
§Example
use node_auth::auth::get_credentials;
let token = get_credentials(Some("custom-token")).await?;
assert_eq!(token, "custom-token");