From: Harmon Date: Fri, 7 Jan 2022 11:22:39 +0000 (-0600) Subject: Allow OAuth2BearerHandler to be used as auth parameter for API X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5a2a3fc6020b6fe91141a753a2e293976addf48e;p=tweepy.git Allow OAuth2BearerHandler to be used as auth parameter for API --- diff --git a/tweepy/__init__.py b/tweepy/__init__.py index 3747b1b..69069d1 100644 --- a/tweepy/__init__.py +++ b/tweepy/__init__.py @@ -11,7 +11,8 @@ __license__ = 'MIT' from tweepy.api import API from tweepy.auth import ( - AppAuthHandler, OAuthHandler, OAuth2AppHandler, OAuth2Handler + AppAuthHandler, OAuthHandler, OAuth2AppHandler, OAuth2BearerHandler, + OAuth2Handler ) from tweepy.cache import Cache, FileCache, MemoryCache from tweepy.client import Client, Response diff --git a/tweepy/auth.py b/tweepy/auth.py index 7ac26ac..472004f 100644 --- a/tweepy/auth.py +++ b/tweepy/auth.py @@ -172,6 +172,9 @@ class OAuth2BearerHandler(AuthBase): request.headers['Authorization'] = 'Bearer ' + self.bearer_token return request + def apply_auth(self): + return self + class OAuth2AppHandler(AuthHandler): """Application-only authentication handler"""