ramosbugs / openidconnect-rs

OpenID Connect Library for Rust
MIT License
426 stars 103 forks source link

Examples cannot be reproduced #178

Closed JosiahParry closed 4 months ago

JosiahParry commented 4 months ago

I'm trying to get started by using the examples here.

I think the issue is that the examples are part of your workspace so the use of reqwest.

For example using the gitlab example results in the following compiler error:

error[E0433]: failed to resolve: could not find `ClientBuilder` in `blocking`
  --> src/main.rs:53:42
   |
53 |     let http_client = reqwest::blocking::ClientBuilder::new()
   |                                          ^^^^^^^^^^^^^ could not find `ClientBuilder` in `blocking`
   |
help: consider importing one of these structs
   |
1  + use reqwest::ClientBuilder;
   |
1  + use reqwest::blocking::ClientBuilder;

Removing use openidconnect::reqwest; and adding reqwest = { version = "0.12.5", features = ["blocking"] } to the Cargo.toml results in another compiler error with unsatisfied trait bounds on the http_client when using the discover() associated function.

error[E0277]: expected a `Fn(HttpRequest)` closure, found `reqwest::blocking::Client`
   --> src/main.rs:63:74
    |
63  | ... = CoreProviderMetadata::discover(&issuer_url, &http_client)
    |       ------------------------------               ^^^^^^^^^^^ expected an `Fn(HttpRequest)` closure, found `reqwest::blocking::Client`
    |       |
    |       required by a bound introduced by this call
    |
    = help: the trait `Fn(HttpRequest)` is not implemented for `reqwest::blocking::Client`, which is required by `&reqwest::blocking::Client: Fn(HttpRequest)`
    = note: required for `&reqwest::blocking::Client` to implement `Fn(HttpRequest)`

I think one way to improve the onboarding for users would be to make the examples/ directory standalone and not part of the crate's workspace. This would make it reproducible.

ramosbugs commented 4 months ago

The main branch corresponds to the 4.0 release, currently in alpha. Please be sure you're using the examples from the same version of the crate you're importing.

ramosbugs commented 4 months ago

e.g., https://github.com/ramosbugs/openidconnect-rs/tree/3.5.0