Skip to content
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

Throw a more helpful exception when oauth_consumer_key is missing for OAuth1 #574

Closed
johtso opened this issue Apr 1, 2015 · 4 comments
Closed

Comments

@johtso
Copy link
Contributor

johtso commented Apr 1, 2015

Currently you get this very cryptic traceback:

Traceback (most recent call last):
  File "/apps/api/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
    return view_func(*args, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/rest_framework/views.py", line 452, in dispatch
    response = self.handle_exception(exc)
  File "/apps/api/venv/local/lib/python2.7/site-packages/rest_framework/views.py", line 449, in dispatch
    response = handler(request, *args, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/apps/api/code/api/latest/views.py", line 1225, in api_social_auth
    user = request.backend.do_auth(token, details=details, request=request)
  File "/apps/api/venv/local/lib/python2.7/site-packages/social/backends/oauth.py", line 192, in do_auth
    data = self.user_data(access_token)
  File "/apps/api/venv/local/lib/python2.7/site-packages/social/backends/twitter.py", line 37, in user_data
    auth=self.oauth_auth(access_token)
  File "/apps/api/venv/local/lib/python2.7/site-packages/social/backends/base.py", line 228, in get_json
    return self.request(url, *args, **kwargs).json()
  File "/apps/api/venv/local/lib/python2.7/site-packages/social/backends/base.py", line 221, in request
    response = request(method, url, *args, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 450, in request
    prep = self.prepare_request(req)
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests/sessions.py", line 381, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests/models.py", line 308, in prepare
    self.prepare_auth(auth, url)
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests/models.py", line 495, in prepare_auth
    r = auth(self)
  File "/apps/api/venv/local/lib/python2.7/site-packages/requests_oauthlib/oauth1_auth.py", line 87, in __call__
    unicode(r.url), unicode(r.method), None, r.headers)
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 293, in sign
    request.oauth_params.append(('oauth_signature', self.get_oauth_signature(request)))
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 128, in get_oauth_signature
    uri, headers, body = self._render(request)
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/__init__.py", line 199, in _render
    headers = parameters.prepare_headers(request.oauth_params, request.headers, realm=realm)
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 31, in wrapper
    return target(params, *args, **kwargs)
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/parameters.py", line 57, in prepare_headers
    escaped_value = utils.escape(value)
  File "/apps/api/venv/local/lib/python2.7/site-packages/oauthlib/oauth1/rfc5849/utils.py", line 56, in escape
    'Got %s of type %s.' % (u, type(u)))
ValueError: Only unicode objects are escapable. Got None of type <type 'NoneType'>.
@omab
Copy link
Owner

omab commented Apr 4, 2015

Do you have the complete traceback?

@omab omab added the incomplete label Apr 4, 2015
@johtso
Copy link
Contributor Author

johtso commented Apr 7, 2015

@omab sorry, somehow managed to cut off the last line, updated.

@omab omab closed this as completed in e67b622 Apr 7, 2015
@omab
Copy link
Owner

omab commented Apr 7, 2015

That change should get rid of the issue and raise a more simpler exception.

@omab omab removed the incomplete label Apr 7, 2015
@johtso
Copy link
Contributor Author

johtso commented Apr 7, 2015

Awesome! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants