Support
Quality
Security
License
Reuse
kandi has reviewed tweepy and discovered the below as its top functions. This is intended to give you an instant insight into tweepy implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
Twitter for Python!
See all related Code Snippets
QUESTION
How to solve AttributeError: 'Client' object has no attribute 'apply_auth'?
Asked 2022-Apr-08 at 20:48I'm having trouble with new and old documentation of tweepy, it seems that everything that worked in previous versions, but there are a lot of changes, I have a problem making it work right now. Any ideas why I have this error?
import tweepy
client = tweepy.Client(bearer_token='[redacted]',
consumer_key='[redacted]',
consumer_secret='[redacted]',
access_token='[redacted]',
access_token_secret='[redacted]')
api = tweepy.API(client)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print(tweet.text)
I get this error
AttributeError: 'Client' object has no attribute 'apply_auth'
ANSWER
Answered 2022-Apr-08 at 18:25First of all, you should IMMEDIATELY refresh all your personnal and applications tokens.
Anyone can access the Twitter API on your behalf, it's like sharing your password publicly.
About your question: the tweepy.Client
is used to access the version 2 of the Twitter API, while the tweepy.API
is used to access the version 1.1 of the Twitter api.
So you can use them side by side, but they can not be mixed that way.
A quick fix could be:
auth = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret, access_token, access_token_secret
)
api = tweepy.API(auth)
public_tweets = api.home_timeline()
for tweet in public_tweets:
print(tweet.text)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source