yoshidan / google-cloud-rust

Google Cloud Client Libraries for Rust.
MIT License
222 stars 80 forks source link

with_credentials not in the latest version of the crate google_cloud_default #138

Closed omofolarin closed 1 year ago

omofolarin commented 1 year ago

Hi, I'm trying to use with_credentials, but it appears not to be in the latest version of the crate although it is in the main branch. Also, importing the git repo as a dependency doesn't seem to work (maybe because the repo is a workspace). Please what can I do?

yoshidan commented 1 year ago

This cargo.toml and code will work. You may want to re-create Cargo.lock.

use google_cloud_default::WithAuthExt;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let file = google_cloud_auth::credentials::CredentialsFile::new().await?;
    let storage_config = google_cloud_storage::client::ClientConfig::default().with_credentials(file).await?;
    let _storage_client = google_cloud_storage::client::Client::new(storage_config);
    Ok(())
}

Cargo.toml

[package]
name = "test"
version = "0.1.0"
edition = "2021"

[dependencies]
google-cloud-spanner = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main", features=["trace"]}
google-cloud-pubsub = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main", features=["trace", "bytes"]}
google-cloud-storage = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main", default-features=false, features=["trace", "rustls-tls"]}
google-cloud-gax = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main" }
google-cloud-auth = { git = "https://github.com/yoshidan/google-cloud-rust", default-features=false, branch="main", features=["rustls-tls"]}
google-cloud-token = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main" }
google-cloud-googleapis= { git = "https://github.com/yoshidan/google-cloud-rust",branch="main" }
google-cloud-default = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main", default-features=false, features=["spanner", "storage", "pubsub", "rustls-tls"]}
google-cloud-spanner-derive = { git = "https://github.com/yoshidan/google-cloud-rust",branch="main"}

cargo tree | grep google-cloud

├── google-cloud-auth v0.9.1 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   ├── google-cloud-metadata v0.3.2 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   ├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
├── google-cloud-default v0.1.1 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   ├── google-cloud-auth v0.9.1 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   ├── google-cloud-gax v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   │   ├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   ├── google-cloud-metadata v0.3.2 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   ├── google-cloud-pubsub v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   │   ├── google-cloud-gax v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   │   ├── google-cloud-googleapis v0.8.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   │   ├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   ├── google-cloud-spanner v0.18.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   │   ├── google-cloud-gax v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   │   ├── google-cloud-googleapis v0.8.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   │   ├── google-cloud-longrunning v0.13.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│   │   │   ├── google-cloud-gax v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   │   │   ├── google-cloud-googleapis v0.8.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   │   ├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
│   └── google-cloud-storage v0.10.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
│       ├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-gax v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-googleapis v0.8.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-pubsub v0.14.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-spanner v0.18.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-spanner-derive v0.1.0 (proc-macro) (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5)
├── google-cloud-storage v0.10.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
├── google-cloud-token v0.1.0 (https://github.com/yoshidan/google-cloud-rust?branch=main#0479a4f5) (*)
omofolarin commented 1 year ago

Thank you so much for the response. It worked.