Simplify OAuth2AppHandler
authorHarmon <Harmon758@gmail.com>
Fri, 7 Jan 2022 11:31:40 +0000 (05:31 -0600)
committerHarmon <Harmon758@gmail.com>
Sat, 8 Jan 2022 00:19:27 +0000 (18:19 -0600)
tweepy/auth.py

index a6af3ccf599496d1542e3a08c8a0c6529d90a7d0..c6b798e442aec93e94584b72d1222b4b17e5def2 100644 (file)
@@ -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)