flask-oauth
flask-oauth copied to clipboard
OAuthException: Invalid response from twitter
All of sudden few days ago i started getting this 401 error from Twitter
This seems similar to https://dev.twitter.com/discussions/16443 but I'm calling authorize() with callback and oauth_verifier param is passed.
I was having similar issue, found explicitly clearing out the oauth tokens in the session between authentication requests solved my issue. Did not find similar issue in facebook, which is why it was slightly confusing.
Hey @lucasvickers, how exactly did you clear out the oauth tokens in between requests? I've been running into similar issues.
Sorry for missing this update,
I used the code
if session.has_key('twitter_oauth_tokens'):
del session['twitter_oauth_tokens']
where my oauth getter/setter references that key
@twitter.tokengetter
def get_twitter_oauth_token():
...
return session.get('twitter_oauth_tokens')
fwiw, I'm seeing the same issue (with some automatic pingdom authentication to our app), I have yet to see the content of the exception (but I trapped it as I relate in #12). I'm not sure what @lucasvickers refers to, it seems that these session keys are specific to his app (flask_auth session data seems to be of the shape: self.name + '_oauthtok')
I too am seeing this error if the user visits this route when they have already authenticated with twitter:
@app.route('/login/') def login(): """Calling into authorize will cause the OpenID auth machinery to kick in. When all worked out as expected, the remote application will redirect back to the callback URL provided. """
return twitter.authorize(callback=url_for('oauth_authorized', next=request.args.get('next') or request.referrer or None))
I think I've worked around it by just checking for the existence of a token in the session and redirecting to an authenticated view.
I got one instance of this exception last night. The message (data) was: "Failed to exchange tokens" Probably some lag on twitter side.
Just got the same issue with the callback failing with Invalid / expired Token. Resolved it with @lucasvickers advice by clearing explicitly the token in the session. Flask-OAuth==0.12
^^Thanks buds!
I'm facing following error:
OAuthException: Invalid response from twitter
What should I do?