Expose the exchange_oauth2_code function from proxmox-notify's SMTP API.
This will allow PVE to expose it as an endpoint, which is needed for
the initial OAuth2 refresh token exchange that has to run in the
backend.

Signed-off-by: Arthur Bied-Charreton <[email protected]>
---
 common/src/bindings/notify.rs | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/common/src/bindings/notify.rs b/common/src/bindings/notify.rs
index 8316013..a0f79e4 100644
--- a/common/src/bindings/notify.rs
+++ b/common/src/bindings/notify.rs
@@ -26,7 +26,7 @@ pub mod proxmox_rs_notify {
         DeleteableSendmailProperty, SendmailConfig, SendmailConfigUpdater,
     };
     use proxmox_notify::endpoints::smtp::{
-        DeleteableSmtpProperty, SmtpConfig, SmtpConfigUpdater, 
SmtpPrivateConfig,
+        DeleteableSmtpProperty, SmtpAuthMethod, SmtpConfig, SmtpConfigUpdater, 
SmtpPrivateConfig,
         SmtpPrivateConfigUpdater,
     };
     use proxmox_notify::endpoints::webhook::{
@@ -445,6 +445,29 @@ pub mod proxmox_rs_notify {
         )
     }
 
+    /// Method: Exchange an OAuth2 authorization code for a refresh token.
+    ///
+    /// See [`api::smtp::exchange_oauth2_code`]
+    #[export(serialize_error)]
+    pub fn exchange_smtp_oauth2_code(
+        #[try_from_ref] _this: &NotificationConfig,
+        auth_method: SmtpAuthMethod,
+        client_id: String,
+        client_secret: String,
+        tenant_id: Option<String>,
+        authorization_code: String,
+        redirect_uri: String,
+    ) -> Result<String, HttpError> {
+        api::smtp::exchange_oauth2_code(
+            auth_method,
+            client_id,
+            client_secret,
+            tenant_id,
+            authorization_code,
+            redirect_uri,
+        )
+    }
+
     /// Method: Delete an SMTP endpoint.
     ///
     /// See [`api::smtp::delete_endpoint`].
-- 
2.47.3



Reply via email to