From 5a2a3fc6020b6fe91141a753a2e293976addf48e Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 7 Jan 2022 05:22:39 -0600 Subject: [PATCH] Allow OAuth2BearerHandler to be used as auth parameter for API --- tweepy/__init__.py | 3 ++- tweepy/auth.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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""" -- 2.25.1