I'm using Django AllAuth for twitter login, and it's working perfectly and saving the token and token secret to the Social Account Tokens table.
I'm then trying to use Tweepy to send a tweet on the user's behalf (yes, the scope allows that).
But when I try to send the tweet, I get tweepy.error.TweepError: [{'code': 32, 'message': 'Could not authenticate you.'}]
Here's the auth code:
def auth_tweepy(user):
twitter_auth_keys = settings.TWITTER_AUTH_KEYS
auth = tweepy.OAuthHandler(
twitter_auth_keys['consumer_key'],
twitter_auth_keys['consumer_secret']
)
user_auth = SocialToken.objects.get(account__user=user, account__provider='twitter')
auth.set_access_token(
user_auth.token,
user_auth.token_secret
)
return tweepy.API(auth)
def send_tweet(tweet_content):
api = auth_tweepy(user)
try:
api.update_status(tweet_content)
except tweepy.TweepError as error:
if error.api_code == 187:
print('duplicate message')
I dont think the tokens are expired bc I JUST logged in. Any ideas what might cause the 32 error in this case?