Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Whoa there!
- The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake
- .def _twitter(self):
- # Get the access token supplied
- oauth_token = self.test_credentials.get('oauth_token')
- oauth_token_secret = self.test_credentials.get('oauth_token_secret')
- if not oauth_token or not oauth_token_secret:
- raise AuthenticationException('Invalid request format.', 400)
- auth = tweepy.OAuthHandler(current_app.config['TWITTER_CONSUMER_KEY'], current_app.config['TWITTER_CONSUMER_SECRET'])
- auth.set_access_token(oauth_token, oauth_token_secret)
- api = tweepy.API(auth)
- user = api.verify_credentials()
- if not user:
- raise AuthenticationException('Unable to verify credentials with remote server.', 500)
- # Save the user
- auth_string = self._auth_string(unicode(user.id_str))
- stored_user = User.query(User.auth_ids == auth_string).get()
- if not stored_user:
- return User(name=user.name)
- if stored_user and not stored_user.name:
- stored_user.name = user.name
- stored_user.put()
- return stored_user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement