Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. Whoa there!
  2. 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
  3.  
  4. .def _twitter(self):
  5. # Get the access token supplied
  6. oauth_token = self.test_credentials.get('oauth_token')
  7. oauth_token_secret = self.test_credentials.get('oauth_token_secret')
  8. if not oauth_token or not oauth_token_secret:
  9. raise AuthenticationException('Invalid request format.', 400)
  10.  
  11. auth = tweepy.OAuthHandler(current_app.config['TWITTER_CONSUMER_KEY'], current_app.config['TWITTER_CONSUMER_SECRET'])
  12. auth.set_access_token(oauth_token, oauth_token_secret)
  13.  
  14. api = tweepy.API(auth)
  15. user = api.verify_credentials()
  16.  
  17. if not user:
  18. raise AuthenticationException('Unable to verify credentials with remote server.', 500)
  19.  
  20. # Save the user
  21. auth_string = self._auth_string(unicode(user.id_str))
  22.  
  23. stored_user = User.query(User.auth_ids == auth_string).get()
  24.  
  25. if not stored_user:
  26. return User(name=user.name)
  27.  
  28. if stored_user and not stored_user.name:
  29. stored_user.name = user.name
  30. stored_user.put()
  31.  
  32. return stored_user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement