Change AsyncBaseStream._connect oauth_1 parameter to oauth_client
authorHarmon <Harmon758@gmail.com>
Tue, 4 Oct 2022 20:06:14 +0000 (15:06 -0500)
committerHarmon <Harmon758@gmail.com>
Tue, 4 Oct 2022 20:06:14 +0000 (15:06 -0500)
tweepy/asynchronous/streaming.py

index 530179cf940dad985b00dc42d9ddbdbfa00ec4ff..7a19d445562697c435283671e89d6d3e7bdcbc2c 100644 (file)
@@ -38,7 +38,8 @@ class AsyncBaseStream:
         )
 
     async def _connect(
-        self, method, url, params=None, headers=None, body=None, oauth_1=False
+        self, method, url, params=None, headers=None, body=None,
+        oauth_client=None
     ):
         error_count = 0
         # https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/connecting
@@ -60,11 +61,7 @@ class AsyncBaseStream:
         try:
             while error_count <= self.max_retries:
                 try:
-                    if oauth_1:
-                        oauth_client = OAuthClient(
-                            self.consumer_key, self.consumer_secret,
-                            self.access_token, self.access_token_secret
-                        )
+                    if oauth_client:
                         url, headers, body = oauth_client.sign(
                             url, http_method=method, headers=headers, body=body
                         )
@@ -256,10 +253,12 @@ class AsyncStream(AsyncBaseStream):
     async def _connect(
         self, method, endpoint, params={}, headers=None, body=None
     ):
+        oauth_client = OAuthClient(self.consumer_key, self.consumer_secret,
+                                   self.access_token, self.access_token_secret)
         url = f"https://stream.twitter.com/1.1/{endpoint}.json"
         url = str(URL(url).with_query(sorted(params.items())))
         await super()._connect(
-            method, url, headers=headers, body=body, oauth_1=True
+            method, url, headers=headers, body=body, oauth_client=oauth_client
         )
 
     def filter(self, *, follow=None, track=None, locations=None,