Remove API.me, AuthHandler.get_username, and OAuthHandler.get_username
authorHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 18:44:20 +0000 (13:44 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 7 Apr 2021 18:48:23 +0000 (13:48 -0500)
docs/api.rst
tests/test_api.py
tweepy/api.py
tweepy/auth.py

index b8a601b2107288b3174788d08494933e0d06c5ba..90025ea6e2f67972785a2f061330916bf8865d8b 100644 (file)
@@ -136,16 +136,6 @@ Follow, search, and get users
 .. automethod:: API.get_user
 
 
-User methods
-------------
-
-.. method:: API.me()
-
-   Returns the authenticated user's information.
-
-   :rtype: :class:`User` object
-
-
 Direct Message Methods
 ----------------------
 
index 66077690d38b69bd580240749e989480ee7b563b..f123363e9693618eb2510d6559850c67395f6c4c 100644 (file)
@@ -130,18 +130,13 @@ class TweepyAPITests(TweepyTestCase):
     def testsearchusers(self):
         self.api.search_users('twitter')
 
-    @tape.use_cassette('testme.json')
-    def testme(self):
-        me = self.api.me()
-        self.assertEqual(me.screen_name, username)
-
     @tape.use_cassette('testlistdirectmessages.json')
     def testlistdirectmessages(self):
         self.api.list_direct_messages()
 
     @tape.use_cassette('testsendanddestroydirectmessage.json')
     def testsendanddestroydirectmessage(self):
-        me = self.api.me()
+        me = self.api.verify_credentials()
 
         # send
         sent_dm = self.api.send_direct_message(me.id, text='test message')
@@ -200,7 +195,7 @@ class TweepyAPITests(TweepyTestCase):
 
     @tape.use_cassette('testupdateprofilecolors.json')
     def testupdateprofilecolors(self):
-        original = self.api.me()
+        original = self.api.verify_credentials()
         updated = self.api.update_profile(profile_link_color='D0F900')
 
         # restore colors
@@ -225,7 +220,7 @@ class TweepyAPITests(TweepyTestCase):
 
     @tape.use_cassette('testupdateprofile.json')
     def testupdateprofile(self):
-        original = self.api.me()
+        original = self.api.verify_credentials()
         profile = {
             'name': 'Tweepy test 123',
             'location': 'pytopia',
index 47592e616b50351750a46f03bb3efff67e3cf5a9..9a7e36ed262d4a0b409d93185d398b13c0ddfc78 100644 (file)
@@ -1843,10 +1843,6 @@ class API:
             ), command='STATUS', media_id=media_id, upload_api=True, **kwargs
         )
 
-    def me(self):
-        """ Get the authenticated user """
-        return self.get_user(screen_name=self.auth.get_username())
-
     @payload('direct_message')
     def get_direct_message(self, id, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/get-event
index dc6c968a9d3abbe4282a8a41aa9000436840fbdd..7d481f691e69f4acd8240ccf910d4fb1ce6613de 100644 (file)
@@ -25,10 +25,6 @@ class AuthHandler:
         """Apply authentication headers to request"""
         raise NotImplementedError
 
-    def get_username(self):
-        """Return the username of the authenticated user"""
-        raise NotImplementedError
-
 
 class OAuthHandler(AuthHandler):
     """OAuth authentication handler"""
@@ -134,17 +130,6 @@ class OAuthHandler(AuthHandler):
         except Exception as e:
             raise TweepyException(e)
 
-    def get_username(self):
-        if self.username is None:
-            api = API(self)
-            user = api.verify_credentials()
-            if user:
-                self.username = user.screen_name
-            else:
-                raise TweepyException('Unable to get username,'
-                                      ' invalid oauth token!')
-        return self.username
-
 
 class OAuth2Bearer(AuthBase):
     def __init__(self, bearer_token):