Browse Source

Refactor OAuth2 token exchange and refresh error handling

pull/6388/head
Henning 3 weeks ago
parent
commit
8927a1fea6
  1. 6
      src/api/admin.rs
  2. 2
      src/config.rs
  3. 6
      src/mail.rs

6
src/api/admin.rs

@ -452,11 +452,7 @@ async fn oauth2_callback(params: OAuth2CallbackParams) -> Result<Html<String>, E
("client_secret", &client_secret),
];
let response = match make_http_request(Method::POST, &token_url)?
.form(&form_params)
.send()
.await
{
let response = match make_http_request(Method::POST, &token_url)?.form(&form_params).send().await {
Ok(res) => res,
Err(e) => err!(format!("OAuth2 Token Exchange Error: {e}")),
};

2
src/config.rs

@ -898,7 +898,7 @@ make_config! {
/// SMTP OAuth2 Refresh Token |> OAuth2 Refresh Token for obtaining new access tokens
smtp_oauth2_refresh_token: Pass, true, option;
/// SMTP OAuth2 Scopes |> Comma-separated list of OAuth2 scopes
smtp_oauth2_scopes: String, true, def, "".to_string();
smtp_oauth2_scopes: String, true, def, String::new();
/// SMTP connection timeout |> Number of seconds when to stop trying to connect to the SMTP server
smtp_timeout: u64, true, def, 15;
/// Server name sent during HELO |> By default this value should be the machine's hostname, but might need to be changed in case it trips some anti-spam filters

6
src/mail.rs

@ -56,11 +56,7 @@ pub async fn refresh_oauth2_token() -> Result<OAuth2Token, Error> {
("client_secret", &client_secret),
];
let response = match make_http_request(reqwest::Method::POST, &token_url)?
.form(&form_params)
.send()
.await
{
let response = match make_http_request(reqwest::Method::POST, &token_url)?.form(&form_params).send().await {
Ok(res) => res,
Err(e) => err!(format!("OAuth2 Token Refresh Error: {e}")),
};

Loading…
Cancel
Save