From 770c76297c008591f5b229a180a149c1e9dd5d18 Mon Sep 17 00:00:00 2001
From: Stefan Huber <shuber@sthu.org>
Date: Mon, 2 Sep 2024 08:51:38 +0200
Subject: [PATCH] Improve compatibility with Debian

---
 README.md            | 6 ++++++
 oauth2_token_manager | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2e89f52..5d18910 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,12 @@ These can be installed using pip:
 pip install -r requirements.txt
 ```
 
+Or in Debian-based Linux systems:
+
+```sh
+sudo apt install python3-platformdirs python3-requests
+```
+
 
 ## Usage
 
diff --git a/oauth2_token_manager b/oauth2_token_manager
index aeb9810..f03aa99 100755
--- a/oauth2_token_manager
+++ b/oauth2_token_manager
@@ -402,7 +402,10 @@ Example usage:
     if args.debug:
         args.verbose = True
 
-    cachedir = user_cache_dir("oauth2_token_manager", ensure_exists=True)
+    # Debian Bookworm's version does not know ensure_exists
+    # cachedir = user_cache_dir("oauth2_token_manager", ensure_exists=True)
+    cachedir = user_cache_dir("oauth2_token_manager")
+    os.makedirs(cachedir, mode=0o700, exist_ok=True)
     args.tokenfile = os.path.join(cachedir, args.tokenfile)
 
     debug_log("Token file: ", args.tokenfile)
-- 
2.39.5