From fa73d7059d97aaffd318e8cc59da739bb0ad9b68 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 18 May 2022 05:33:56 -0500 Subject: [PATCH] Percent-encode colons in URL query values for AsyncClient.request --- tweepy/asynchronous/client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tweepy/asynchronous/client.py b/tweepy/asynchronous/client.py index f03883a..3bef8f9 100644 --- a/tweepy/asynchronous/client.py +++ b/tweepy/asynchronous/client.py @@ -75,6 +75,14 @@ class AsyncBaseClient(BaseClient): url, headers, body = oauth_client.sign( url, method, headers=headers ) + # oauthlib.oauth1.Client (OAuthClient) expects colons in query + # values (e.g. in timestamps) to be percent-encoded, while + # aiohttp.ClientSession does not automatically encode them + before_query, question_mark, query = url.partition('?') + url = URL( + f"{before_query}?{query.replace(':', '%3A')}", + encoded = True + ) params = None else: headers["Authorization"] = f"Bearer {self.bearer_token}" -- 2.25.1