Python Forum

Full Version: tweepy:invalid or expired token
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, thanks for your help, I want to find a twitter user thanks to tweepy, I have already tried to generate a new key, I've also tried with a token, but it says:

Error:
"Traceback (most recent call last): File "C:/Users/enora/PycharmProjects/untitled2/Cluedo1.py", line 33, in <module> user = api.get_user(screen_name = 'suspect_jean_michel') File "C:\Python34\lib\site-packages\tweepy\binder.py", line 245, in _call return method.execute() File "C:\Python34\lib\site-packages\tweepy\binder.py", line 229, in execute raise TweepError(error_msg, resp, api_code=api_error_code) tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]"
Here is my code:

#importer les modules
import googlemaps
import tweepy
import urllib.request
import json

from tweepy import API


#authentification twitter
consumer_key="REMOVEDl"
key=consumer_key
consumer_secret="REMOVED"
secret=consumer_secret
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)
api = tweepy.API(auth)

user = api.get_user(screen_name = 'suspect_jean_michel')
up :)
It's extremely difficult for a regular forum to help with issues like this. The API says your token is invalid or expired - if that's the case, it should be clear how to fix it, and if it's not, then you probably need to contact whoever maintains the API.