mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-25 11:00:52 +00:00
Use oauth token for basic bearer auth in Rust. (#2161)
* Use oauth token for basic bearer auth in Rust. * Add bearer_access_token instead of reusing oauth_access_token
This commit is contained in:
parent
1d08296f96
commit
bc6c94d412
@ -78,9 +78,16 @@ impl {{{classname}}} for {{{classname}}}Client {
|
||||
{{/isKeyInHeader}}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
{{^isBasicBearer}}
|
||||
if let Some(ref auth_conf) = configuration.basic_auth {
|
||||
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
|
||||
};
|
||||
{{/isBasicBearer}}
|
||||
{{#isBasicBearer}}
|
||||
if let Some(ref token) = configuration.bearer_access_token {
|
||||
req_builder = req_builder.bearer_auth(token.to_owned());
|
||||
};
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
if let Some(ref token) = configuration.oauth_access_token {
|
||||
|
@ -8,6 +8,7 @@ pub struct Configuration {
|
||||
pub client: reqwest::Client,
|
||||
pub basic_auth: Option<BasicAuth>,
|
||||
pub oauth_access_token: Option<String>,
|
||||
pub bearer_access_token: Option<String>,
|
||||
pub api_key: Option<ApiKey>,
|
||||
// TODO: take an oauth2 token source, similar to the go one
|
||||
}
|
||||
@ -33,6 +34,7 @@ impl Default for Configuration {
|
||||
client: reqwest::Client::new(),
|
||||
basic_auth: None,
|
||||
oauth_access_token: None,
|
||||
bearer_access_token: None,
|
||||
api_key: None,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user