From 2c4272110ab49da338e8dfe29e551935c3b73104 Mon Sep 17 00:00:00 2001 From: ModerateWinGuy Date: Tue, 7 Oct 2025 11:30:28 +1300 Subject: [PATCH] fix(praw): fixed auth error for new praw version --- bdfr/oauth2.py | 8 +++++--- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bdfr/oauth2.py b/bdfr/oauth2.py index ead0553..6d1ba52 100644 --- a/bdfr/oauth2.py +++ b/bdfr/oauth2.py @@ -9,7 +9,9 @@ import socket from pathlib import Path import praw +import prawcore import requests +from praw.util.token_manager import BaseTokenManager from bdfr.exceptions import BulkDownloaderException, RedditAuthenticationError @@ -87,13 +89,13 @@ class OAuth2Authenticator: client.close() -class OAuth2TokenManager(praw.reddit.BaseTokenManager): +class OAuth2TokenManager(BaseTokenManager): def __init__(self, config: configparser.ConfigParser, config_location: Path): super(OAuth2TokenManager, self).__init__() self.config = config self.config_location = config_location - def pre_refresh_callback(self, authorizer: praw.reddit.Authorizer): + def pre_refresh_callback(self, authorizer: prawcore.auth.BaseAuthorizer): if authorizer.refresh_token is None: if self.config.has_option("DEFAULT", "user_token"): authorizer.refresh_token = self.config.get("DEFAULT", "user_token") @@ -101,7 +103,7 @@ class OAuth2TokenManager(praw.reddit.BaseTokenManager): else: raise RedditAuthenticationError("No auth token loaded in configuration") - def post_refresh_callback(self, authorizer: praw.reddit.Authorizer): + def post_refresh_callback(self, authorizer: prawcore.auth.BaseAuthorizer): self.config.set("DEFAULT", "user_token", authorizer.refresh_token) with Path(self.config_location).open(mode="w") as file: self.config.write(file, True) diff --git a/pyproject.toml b/pyproject.toml index c88008d..fa3dc77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ "beautifulsoup4>=4.10.0", "click>=8.0.0", "dict2xml>=1.7.0", - "praw>=7.2.0", + "praw>=7.8.1", "pyyaml>=5.4.1", "requests>=2.25.1", "yt-dlp>=2022.11.11",