Struct VertexAIAuth
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§
§impl VertexAIAuth
impl VertexAIAuth
pub 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.
pub 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§
§impl AuthProvider for VertexAIAuth
impl AuthProvider for VertexAIAuth
§fn ws_url(&self, model: &GeminiModel) -> String
fn ws_url(&self, model: &GeminiModel) -> String
Build the WebSocket URL for the given model.
§fn rest_url(
&self,
endpoint: ServiceEndpoint,
model: Option<&GeminiModel>,
) -> String
fn rest_url( &self, endpoint: ServiceEndpoint, model: Option<&GeminiModel>, ) -> String
Build a REST API URL for the given service endpoint and model. Read more
§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).
§fn query_params(&self) -> Vec<(String, String)>
fn query_params(&self) -> Vec<(String, String)>
Query parameters to append to the URL (e.g., API key).
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