I'm implementing a function that returns an instance of BasicClient
from the oauth2
crate, but I'm encountering a type mismatch error.
Here's the function:
fn create_oauth_client(port: u16) -> Result<BasicClient> {
// Unimportant code omitted
let client = BasicClient::new(client_id)
.set_auth_uri(auth_url)
.set_token_uri(token_url)
.set_redirect_uri(RedirectUrl::new(format!("http://localhost:{port}"))?);
Ok(client)
}
However, this results in the following compilation error:
error[E0308]: mismatched types
--> src/auth_service.rs:40:8
|
40 | Ok(client)
| -- ^^^^^^ expected `Client<StandardErrorResponse<...>, ..., ..., ..., ...>`, found `Client<StandardErrorResponse<...>, ..., ..., ..., ..., ..., ..., ..., ..., ...>`
| |
| arguments to this enum variant are incorrect
|
= note: expected struct `oauth2::Client<_, _, _, _, _, EndpointNotSet, _, _, _, EndpointNotSet>`
found struct `oauth2::Client<_, _, _, _, _, EndpointSet, _, _, _, EndpointSet>`
I know if I specify the exact type of client
( Client<StandardErrorResponse<BasicErrorResponseType>, StandardTokenResponse<EmptyExtraTokenFields, BasicTokenType>, StandardTokenIntrospectionResponse<EmptyExtraTokenFields, BasicTokenType>, StandardRevocableToken, StandardErrorResponse<RevocationErrorResponseType>, EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointSet>
), the error goes away, but the type is quite long, which hurts readability.
Is it possible to simplify the return type?