From 91f57f2f6fd50d6ecb53e1f04da53030e80e5996 Mon Sep 17 00:00:00 2001 From: Neil Hooey Date: Mon, 21 Oct 2013 18:29:07 -0400 Subject: [PATCH 1/2] Stop obscuring generate_request_token() failures. --- flask_oauth.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flask_oauth.py b/flask_oauth.py index b21105a..8193860 100644 --- a/flask_oauth.py +++ b/flask_oauth.py @@ -295,8 +295,10 @@ def generate_request_token(self, callback=None): self.expand_url(self.request_token_url), callback, self.request_token_params) if not self.status_okay(resp): - raise OAuthException('Failed to generate request token', - type='token_generation_failed') + msg = "Failed to generate request token." \ + + " Response code: '%s', response content: '%s'" \ + % (resp['status'], content) + raise OAuthException(msg, type='token_generation_failed') data = parse_response(resp, content) if data is None: raise OAuthException('Invalid token response from ' + self.name, From 21454b738bad036f80152dd914d1cf39999ababb Mon Sep 17 00:00:00 2001 From: Neil Hooey Date: Mon, 21 Oct 2013 18:47:51 -0400 Subject: [PATCH 2/2] Mention the "Callback URL" in Twitter's dev settings. If you don't tell people this, their first attempt at getting the example to work will fail without explanation. --- docs/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index e1da1e2..fcd48c3 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -121,6 +121,11 @@ redirected back to. For example:: return twitter.authorize(callback=url_for('oauth_authorized', next=request.args.get('next') or request.referrer or None)) +For the callback to work, you must set a placeholder "Callback URL" in your +app's "Settings" tab at https://dev.twitter.com. The URL configured in this +settings page isn't actually used, but not setting it will prevent the +authorize() call mentioned above from working. + If the application redirects back, the remote application will have passed all relevant information to the `oauth_authorized` function: a special response object with all the data, or ``None`` if the user denied the