pub struct VertexCredentials { /* private fields */ }vertex only.Expand description
Credential source for Vertex AI authentication.
Carries either a static bearer token (no async refresh) or an ADC-backed
TokenProvider that fetches and caches tokens via gcp_auth.
Construct with VertexCredentials::from_token,
VertexCredentials::from_adc, or VertexCredentials::from_env.
Implementations§
Source§impl VertexCredentials
impl VertexCredentials
Sourcepub fn from_token(token: impl Into<String>) -> Self
pub fn from_token(token: impl Into<String>) -> Self
Use a pre-obtained OAuth2 bearer token directly.
The token is used verbatim; no refresh is performed. Suitable for
short-lived scripts or tests where you already have a token (e.g.,
gcloud auth print-access-token).
Sourcepub async fn from_adc() -> Result<Self, Error>
pub async fn from_adc() -> Result<Self, Error>
Use Application Default Credentials via gcp_auth.
Tries, in order:
GOOGLE_APPLICATION_CREDENTIALSenv var (service-account key file)~/.config/gcloud/application_default_credentials.json- GCE instance-metadata server
gcloud auth print-access-token
Tokens are cached and refreshed automatically by gcp_auth. This
constructor is async because provider discovery may involve network
I/O (metadata server probe).
§Errors
Returns an error if no credential source is found or if the initial provider discovery fails.
Sourcepub fn from_env() -> Option<Self>
pub fn from_env() -> Option<Self>
Read credentials from environment variables.
Checks, in order:
VERTEX_ACCESS_TOKEN– if set, constructs afrom_tokencredential.GOOGLE_APPLICATION_CREDENTIALS– if set, returns anfrom_adccredential.
Returns None when neither variable is set.
§Panics
This method calls from_adc() synchronously by blocking on the
current Tokio runtime when GOOGLE_APPLICATION_CREDENTIALS is set.
It will panic if called outside a Tokio runtime context.
Trait Implementations§
Source§impl Clone for VertexCredentials
impl Clone for VertexCredentials
Source§fn clone(&self) -> VertexCredentials
fn clone(&self) -> VertexCredentials
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for VertexCredentials
impl !RefUnwindSafe for VertexCredentials
impl Send for VertexCredentials
impl Sync for VertexCredentials
impl Unpin for VertexCredentials
impl UnsafeUnpin for VertexCredentials
impl !UnwindSafe for VertexCredentials
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more