pub struct VertexAIAuth { /* private fields */ }Expand description
Vertex AI Bearer token authentication.
Uses a project/location pair to construct the Vertex AI WebSocket URL,
and a Bearer token for the Authorization header.
Supports two token modes:
- Fixed (
new): token is set once at construction. Best for WebSocket connections where the token is only needed at connect time. - Refreshable (
with_token_refresher): a closure is called on everyauth_headers()invocation, ensuring fresh tokens for long-running HTTP clients (e.g., generate API calls).
Implementations§
Source§impl VertexAIAuth
impl VertexAIAuth
Sourcepub fn new(
project: impl Into<String>,
location: impl Into<String>,
token: impl Into<String>,
) -> VertexAIAuth
pub fn new( project: impl Into<String>, location: impl Into<String>, token: impl Into<String>, ) -> VertexAIAuth
Create a new Vertex AI auth provider with a fixed token.
The token is stored and reused for all requests. Use this for WebSocket connections where the token is only needed at connect time.
Sourcepub fn with_token_refresher(
project: impl Into<String>,
location: impl Into<String>,
refresher: impl Fn() -> String + Send + Sync + 'static,
) -> VertexAIAuth
pub fn with_token_refresher( project: impl Into<String>, location: impl Into<String>, refresher: impl Fn() -> String + Send + Sync + 'static, ) -> VertexAIAuth
Create a Vertex AI auth provider with a dynamic token refresher.
The refresher closure is called on every auth_headers() invocation,
allowing token refresh for long-running HTTP clients. The closure
should handle caching internally to avoid unnecessary overhead.
Trait Implementations§
Source§impl AuthProvider for VertexAIAuth
impl AuthProvider for VertexAIAuth
Source§fn auth_headers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
VertexAIAuth: 'async_trait,
fn auth_headers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, AuthError>> + Send + 'async_trait>>where
'life0: 'async_trait,
VertexAIAuth: 'async_trait,
HTTP headers for the WebSocket upgrade request (e.g., Bearer token).
Auto Trait Implementations§
impl !Freeze for VertexAIAuth
impl !RefUnwindSafe for VertexAIAuth
impl Send for VertexAIAuth
impl Sync for VertexAIAuth
impl Unpin for VertexAIAuth
impl !UnwindSafe for VertexAIAuth
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
Mutably borrows from an owned value. Read more
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
Converts
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>
Converts
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].