Skip to content

Commit bc6c94d

Browse files
boxdotwing328
authored andcommitted
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
1 parent 1d08296 commit bc6c94d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

modules/openapi-generator/src/main/resources/rust/reqwest/api.mustache

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,16 @@ impl {{{classname}}} for {{{classname}}}Client {
7878
{{/isKeyInHeader}}
7979
{{/isApiKey}}
8080
{{#isBasic}}
81+
{{^isBasicBearer}}
8182
if let Some(ref auth_conf) = configuration.basic_auth {
8283
req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
8384
};
85+
{{/isBasicBearer}}
86+
{{#isBasicBearer}}
87+
if let Some(ref token) = configuration.bearer_access_token {
88+
req_builder = req_builder.bearer_auth(token.to_owned());
89+
};
90+
{{/isBasicBearer}}
8491
{{/isBasic}}
8592
{{#isOAuth}}
8693
if let Some(ref token) = configuration.oauth_access_token {

modules/openapi-generator/src/main/resources/rust/reqwest/configuration.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub struct Configuration {
88
pub client: reqwest::Client,
99
pub basic_auth: Option<BasicAuth>,
1010
pub oauth_access_token: Option<String>,
11+
pub bearer_access_token: Option<String>,
1112
pub api_key: Option<ApiKey>,
1213
// TODO: take an oauth2 token source, similar to the go one
1314
}
@@ -33,6 +34,7 @@ impl Default for Configuration {
3334
client: reqwest::Client::new(),
3435
basic_auth: None,
3536
oauth_access_token: None,
37+
bearer_access_token: None,
3638
api_key: None,
3739
}
3840
}

0 commit comments

Comments
 (0)