Skip to content

Commit

Permalink
Add user_auth parameters to Client.unlike and Client.like
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Harmon758 committed Jan 7, 2022
1 parent 8f38429 commit e88b074
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tweepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def unhide_reply(self, id, *, user_auth=True):

# 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
Expand All @@ -271,7 +271,7 @@ def unlike(self, tweet_id):
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):
Expand Down Expand Up @@ -370,7 +370,7 @@ def get_liked_tweets(self, id, *, user_auth=False, **params):
), data_type=Tweet, user_auth=user_auth
)

def like(self, tweet_id):
def like(self, tweet_id, *, user_auth=True):
"""Like a Tweet.
Parameters
Expand All @@ -390,7 +390,8 @@ def like(self, tweet_id):
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
Expand Down

0 comments on commit e88b074

Please sign in to comment.