From: Harmon Date: Fri, 7 Jan 2022 11:31:40 +0000 (-0600) Subject: Simplify OAuth2AppHandler X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=658aa744dfa95cc119460297e7780f587dd020ca;p=tweepy.git Simplify OAuth2AppHandler --- 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)