yoshidan / google-cloud-rust

Google Cloud Client Libraries for Rust.
MIT License
233 stars 85 forks source link

Example shared in the doc doesn't work for credential file #132

Closed animesh-sharama closed 1 year ago

animesh-sharama commented 1 year ago

I an trying to run the example from the repo:

use google_cloud_auth::credentials::CredentialsFile;
use google_cloud_storage::client::{ClientConfig, Client};
use google_cloud_default::WithAuthExt;

async fn run(cred: CredentialsFile) {
    let config = ClientConfig::default().with_credentials(cred).await.unwrap();
    let client = Client::new(config);
}

The Cargo.toml is:

[dependencies]
google-cloud-storage = "0.9.0"
google-cloud-auth = "0.9.0"
google-cloud-default = { version = "0.1.0", features = ["storage", "google-cloud-metadata"] }

I get the following error:

.with_credentials(cred))
^^^^^^^^^^^^^^^^ method not found in `ClientConfig`

can someone point what am I missing?

yoshidan commented 1 year ago

We have not yet released google-cloud-default with the addition of with_credentials. We plan to release it in a week or two. Until then, please use the main branch directly.

google-cloud-default = { git = "https://github.com/yoshidan/google-cloud-rust", branch="main", 
animesh-sharama commented 1 year ago

directly using main branch results as follows: google-cloud-default = { git = "https://github.com/yoshidan/google-cloud-rust", branch="main"} results into the same error:

.with_credentials(cred))
^^^^^^^^^^^^^^^^ method not found in `ClientConfig`

do I need to configure anything else?

yoshidan commented 1 year ago

If you use the main branch, components other than google-cloud-default must also be in the main branch.

google-cloud-storage =  { git = "https://github.com/yoshidan/google-cloud-rust", branch="main", 
google-cloud-auth =  { git = "https://github.com/yoshidan/google-cloud-rust", branch="main", 

Here is the example.

You can check the cargo tree to make sure that only the main branch is really used and not duplicated in other versions.

$ cargo tree | grep google-cloud-default
├── google-cloud-default v0.1.1 (https://github.com/yoshidan/google-cloud-rust?branch=main#cb14a257)

$cargo tree | grep google-cloud-auth
├── google-cloud-auth v0.9.1 (https://github.com/yoshidan/google-cloud-rust?branch=main#cb14a257) (*)
animesh-sharama commented 1 year ago

yes I am using the main branch for all the components, below is my cargo.toml:

google-cloud-storage =  { git = "https://github.com/yoshidan/google-cloud-rust", branch="main"}
google-cloud-auth =  { git = "https://github.com/yoshidan/google-cloud-rust", branch="main"}
google-cloud-default = { git = "https://github.com/yoshidan/google-cloud-rust", branch="main"}

still the same error,

ClientConfig::default().with_credentials(cred)
 ^^^^^^^^^^^^^^^^ method not found in `ClientConfig`

Now the with_auth also doesn't work:

ClientConfig::default().with_auth()
    |                                                   ^^^^^^^^^ method not found in `ClientConfig`

I checked the cargo tree the output is the same as the one you have shown.

Any other things I can try?

yoshidan commented 1 year ago

You should be able to use it by setting features in google-cloud-default.

google-cloud-default = { git = "https://github.com/yoshidan/google-cloud-rust", branch="main", features=["storage","spanner","pubsub"]}

If it still doesn't improve, could you please paste the Cargo.toml and entire line of source code? I think I can find the flaws.

animesh-sharama commented 1 year ago

thanks its resolved.