From 2eca5c725831a521e33b7a64bff5327daa8ce366 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Tue, 16 Feb 2016 19:40:00 -0800 Subject: [PATCH] Handling missing OAuth token for twitter. --- apps/social/models.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/social/models.py b/apps/social/models.py index 991136c90..3de02cc5f 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -2452,13 +2452,17 @@ class MSocialServices(mongo.Document): logging.user(user, "~BG~FMTwitter import starting...") api = self.twitter_api() + try: + twitter_user = api.me() + except tweepy.TweepError, e: + api = None + if not api: logging.user(user, "~BG~FMTwitter import ~SBfailed~SN: no api access.") self.syncing_twitter = False self.save() return - - twitter_user = api.me() + self.twitter_picture_url = twitter_user.profile_image_url_https self.twitter_username = twitter_user.screen_name self.twitter_refreshed_date = datetime.datetime.utcnow()