From 658aa744dfa95cc119460297e7780f587dd020ca Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 7 Jan 2022 05:31:40 -0600 Subject: [PATCH] Simplify OAuth2AppHandler --- tweepy/auth.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tweepy/auth.py b/tweepy/auth.py index a6af3cc..c6b798e 100644 --- a/tweepy/auth.py +++ b/tweepy/auth.py @@ -134,17 +134,13 @@ class OAuthHandler(AuthHandler): class OAuth2AppHandler(AuthHandler): - """Application-only authentication handler""" - - OAUTH_HOST = 'api.twitter.com' - OAUTH_ROOT = '/oauth2/' def __init__(self, consumer_key, consumer_secret): self.consumer_key = consumer_key self.consumer_secret = consumer_secret self._bearer_token = '' - resp = requests.post(self._get_oauth_url('token'), + resp = requests.post('https://api.twitter.com/oauth2/token', auth=(self.consumer_key, self.consumer_secret), data={'grant_type': 'client_credentials'}) @@ -155,9 +151,6 @@ class OAuth2AppHandler(AuthHandler): self._bearer_token = data['access_token'] - def _get_oauth_url(self, endpoint): - return 'https://' + self.OAUTH_HOST + self.OAUTH_ROOT + endpoint - def apply_auth(self): return OAuth2BearerHandler(self._bearer_token) -- 2.25.1