Skip to content

Stop obscuring generate_request_token() failures. #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions flask_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down