From: Harmon Date: Fri, 7 Jan 2022 08:55:09 +0000 (-0600) Subject: Add user_auth parameters to Client.unlike and Client.like X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e88b07465fbcf6013be89cf938eae718391cc1df;p=tweepy.git 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 --- 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