From 74ad76b36d359f308e18d188fe8483845ac751fe Mon Sep 17 00:00:00 2001 From: magicfelix Date: Tue, 24 Feb 2026 18:14:19 +0100 Subject: [PATCH 1/3] [OAuth2] Allow custom client_id and client_secret --- DOCUMENTATION.md | 16 ++++++++++++++++ config | 6 ++++++ radicale/auth/oauth2.py | 7 ++++++- radicale/config.py | 8 ++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 858bb944..2cd2649b 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1360,6 +1360,22 @@ Endpoint URL for the OAuth2 token Default: (unset) +##### oauth2_client_id + +_(>= 3.5.0)_ + +Client ID used to request the Auth2 token + +Default: `radicale` + +##### oauth2_client_secret + +_(>= 3.5.0)_ + +Client secret used to request the Auth2 token + +Default: (unset) + ##### pam_service _(>= 3.5.0)_ diff --git a/config b/config index 0c5b90a6..7aa81fd1 100644 --- a/config +++ b/config @@ -156,6 +156,12 @@ # OAuth2 token endpoint URL #oauth2_token_endpoint = +# OAuth2 client id +#oauth2_client_id = + +# OAuth2 client secret +#oauth2_client_secret = + # PAM service #pam_serivce = radicale diff --git a/radicale/auth/oauth2.py b/radicale/auth/oauth2.py index 838a786e..87592d0b 100644 --- a/radicale/auth/oauth2.py +++ b/radicale/auth/oauth2.py @@ -34,6 +34,8 @@ class Auth(auth.BaseAuth): def __init__(self, configuration): super().__init__(configuration) self._endpoint = configuration.get("auth", "oauth2_token_endpoint") + self._client_id = configuration.get("auth", "oauth2_client_id") + self._client_secret = configuration.get("auth", "oauth2_client_secret") if not self._endpoint: logger.error("auth.oauth2_token_endpoint URL missing") raise RuntimeError("OAuth2 token endpoint URL is required") @@ -49,8 +51,11 @@ class Auth(auth.BaseAuth): "username": login, "password": password, "grant_type": "password", - "client_id": "radicale", + "client_id": self._client_id, } + if self._client_secret: + req_params["client_secret"] = self._client_secret + req_headers = {"Content-Type": "application/x-www-form-urlencoded"} response = requests.post( self._endpoint, data=req_params, headers=req_headers diff --git a/radicale/config.py b/radicale/config.py index bdca5526..6cc0460d 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -354,6 +354,14 @@ DEFAULT_CONFIG_SCHEMA: types.CONFIG_SCHEMA = OrderedDict([ "value": "", "help": "OAuth2 token endpoint URL", "type": str}), + ("oauth2_client_id", { + "value": "radicale", + "help": "OAuth2 client id", + "type": str}), + ("oauth2_client_secret", { + "value": "", + "help": "OAuth2 client secret", + "type": str}), ("pam_group_membership", { "value": "", "help": "PAM group user should be member of", From cba05fe3dd7f13078b644db76b9363cad0b9b1ed Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 24 Feb 2026 21:00:17 +0100 Subject: [PATCH 2/3] Change oauth2_client_id and secret version to 3.7.0 Update minimum version requirement for oauth2_client_id and oauth2_client_secret. --- DOCUMENTATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 2cd2649b..43bba942 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1362,7 +1362,7 @@ Default: (unset) ##### oauth2_client_id -_(>= 3.5.0)_ +_(>= 3.7.0)_ Client ID used to request the Auth2 token @@ -1370,7 +1370,7 @@ Default: `radicale` ##### oauth2_client_secret -_(>= 3.5.0)_ +_(>= 3.7.0)_ Client secret used to request the Auth2 token From 8e517dacf6fe2b407dee714add19d09a0a34c5b1 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Tue, 24 Feb 2026 21:01:17 +0100 Subject: [PATCH 3/3] Modify OAuth2 client ID and secret in config Updated OAuth2 client ID and secret configuration. --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index 7aa81fd1..18e29a1f 100644 --- a/config +++ b/config @@ -157,10 +157,10 @@ #oauth2_token_endpoint = # OAuth2 client id -#oauth2_client_id = +#oauth2_client_id = radicale -# OAuth2 client secret -#oauth2_client_secret = +# OAuth2 client secret (optional) +#oauth2_client_secret = # PAM service #pam_serivce = radicale