From e88b07465fbcf6013be89cf938eae718391cc1df Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 7 Jan 2022 02:55:09 -0600 Subject: [PATCH] Add user_auth parameters to Client.unlike and Client.like Add user_auth parameters to Client.unlike and Client.like to support OAuth 2.0 Authorization Code Flow with PKCE https://twittercommunity.com/t/manage-likes-incorrectly-mapped-to-oauth-2-0-app-access-token-in-twitter-api-v2-authentication-mapping-documentation/164600 --- tweepy/client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tweepy/client.py b/tweepy/client.py index 995d28b..35125a9 100644 --- a/tweepy/client.py +++ b/tweepy/client.py @@ -248,7 +248,7 @@ class Client: # Likes - def unlike(self, tweet_id): + def unlike(self, tweet_id, *, user_auth=True): """Unlike a Tweet. The request succeeds with no action when the user sends a request to a @@ -271,7 +271,7 @@ class Client: route = f"/2/users/{id}/likes/{tweet_id}" return self._make_request( - "DELETE", route, user_auth=True + "DELETE", route, user_auth=user_auth ) def get_liking_users(self, id, *, user_auth=False, **params): @@ -370,7 +370,7 @@ class Client: ), data_type=Tweet, user_auth=user_auth ) - def like(self, tweet_id): + def like(self, tweet_id, *, user_auth=True): """Like a Tweet. Parameters @@ -390,7 +390,8 @@ class Client: route = f"/2/users/{id}/likes" return self._make_request( - "POST", route, json={"tweet_id": str(tweet_id)}, user_auth=True + "POST", route, json={"tweet_id": str(tweet_id)}, + user_auth=user_auth ) # Manage Tweets -- 2.25.1