Update GCP Auth to 0.12
This commit is contained in:
@@ -8,7 +8,7 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
deadqueue = "0.2"
|
deadqueue = "0.2"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
gcp_auth = "0.11"
|
gcp_auth = "0.12"
|
||||||
reqwest = { version = "0.12", features = ["json", "gzip"] }
|
reqwest = { version = "0.12", features = ["json", "gzip"] }
|
||||||
reqwest-eventsource = "0.6"
|
reqwest-eventsource = "0.6"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
use std::{sync::Arc, time::Duration};
|
|
||||||
|
|
||||||
use console::style;
|
use console::style;
|
||||||
use dialoguer::{theme::ColorfulTheme, Input};
|
use dialoguer::{theme::ColorfulTheme, Input};
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
use indicatif::{ProgressBar, ProgressStyle};
|
use indicatif::{ProgressBar, ProgressStyle};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
tracing_subscriber::fmt().init();
|
tracing_subscriber::fmt().init();
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,12 +1,8 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use gemini_rs::prelude::*;
|
use gemini_rs::prelude::*;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let authentication_manager = Arc::new(AuthenticationManager::new().await?);
|
let authentication_manager = gcp_auth::provider().await?;
|
||||||
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
let api_endpoint = std::env::var("API_ENDPOINT")?;
|
||||||
let project_id = std::env::var("PROJECT_ID")?;
|
let project_id = std::env::var("PROJECT_ID")?;
|
||||||
let location_id = std::env::var("LOCATION_ID")?;
|
let location_id = std::env::var("LOCATION_ID")?;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use gcp_auth::AuthenticationManager;
|
|
||||||
|
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
|
|
||||||
pub trait TokenProvider {
|
pub trait TokenProvider {
|
||||||
@@ -9,18 +7,10 @@ pub trait TokenProvider {
|
|||||||
-> impl std::future::Future<Output = Result<String>> + Send;
|
-> impl std::future::Future<Output = Result<String>> + Send;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TokenProvider for Arc<AuthenticationManager> {
|
impl TokenProvider for Arc<dyn gcp_auth::TokenProvider> {
|
||||||
async fn get_token(&self, scope: &[&str]) -> Result<String> {
|
async fn get_token(&self, scope: &[&str]) -> Result<String> {
|
||||||
match AuthenticationManager::get_token(self, scope).await {
|
let token = self.token(scope).await;
|
||||||
Ok(token) => Ok(token.as_str().to_string()),
|
match token {
|
||||||
Err(e) => Err(e.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TokenProvider for AuthenticationManager {
|
|
||||||
async fn get_token(&self, scope: &[&str]) -> Result<String> {
|
|
||||||
match AuthenticationManager::get_token(self, scope).await {
|
|
||||||
Ok(token) => Ok(token.as_str().to_string()),
|
Ok(token) => Ok(token.as_str().to_string()),
|
||||||
Err(e) => Err(e.into()),
|
Err(e) => Err(e.into()),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user