maoertel / diqwest

Crate to extend `reqwest` to be able to send with digest auth flow.
https://docs.rs/diqwest
MIT License
17 stars 3 forks source link

no method named 'send_with_digest_auth` ? #16

Closed EMCP closed 3 months ago

EMCP commented 4 months ago

I have a minimum viable call I am trying to execute.. but getting method not found

use reqwest::Error;
use diqwest::WithDigestAuth;
use reqwest::{Client, Response};

#[tokio::main]
async fn main() -> Result<(), Error> {

    let public_key = "PUBLICKEY";
    let private_key = "PRIVATEKEY";

    let client = reqwest::Client::new();

    let response: Response = Client::new()
        .get("https://cloud.mongodb.com/api/atlas/v1.0/groups")
        .send_with_digest_auth(public_key, private_key)
        .await?;

    // Check if the request was successful and only then read the text
    if response.status().is_success() {
        let body = response.text().await?;
        println!("{}", body);
    } else {
        // If the response was an error, print the status code and message
        eprintln!("Error: {:?}", response.status());
    }

    Ok(())
}

only spits back

error[E0599]: no method named `send_with_digest_auth` found for struct `RequestBuilder` in the current scope
  --> src/main.rs:16:10
   |
14 |       let response: Response = Client::new()
   |  ______________________________-
15 | |         .get("https://cloud.mongodb.com/api/atlas/v1.0/groups")
16 | |         .send_with_digest_auth(public_key, private_key)
   | |         -^^^^^^^^^^^^^^^^^^^^^ method not found in `RequestBuilder`
   | |_________|
   | 
EMCP commented 4 months ago

the cargo.toml as of now

[package]
name = "dataops-mongodb"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
reqwest = { version = "0.12.1", features = ["json"] }
tokio = { version = "1.36.0", features = ["rt", "rt-multi-thread", "macros"] }
diqwest = "2.0.0"
jeremy-prater commented 3 months ago

I am also seeing this issue. I believe it's a breaking change from reqwest 0.11 -> 0.12. Try and setting your reqwest version to 0.11.10. I just updated all my dependencies and diqwest is broken with latest reqwest I believe.

maoertel commented 3 months ago

Hey guys,

yes, it is due to the reqwest update to 0.12. Will start to look into that this week. :v:

maoertel commented 3 months ago

Solved by #18