GithubHelp home page GithubHelp logo

Comments (6)

ib-lundgren avatar ib-lundgren commented on July 24, 2024

Hey @nhooey, sorry for the slow reply.

Your gist works nicely for me using latest requests-oauthlib from pypi. Would you mind trying in a new virtual env and see if the error persists?

ps. I think you might be in a good position to give some pointers on how to improve that part of the docs too so if you have a few moments any input is much appreciated :)

from requests-oauthlib.

brunsgaard avatar brunsgaard commented on July 24, 2024

@ib-lundgren it seems like your suggestion does not work, at least in my case. Are there any news regarding this 'bug' or am I doing something wrong?

/tmp virtualenv2 ENV
New python executable in ENV/bin/python2
Also creating executable in ENV/bin/python
Installing setuptools, pip...done.
/tmp . ENV/bin/activate.fish
(ENV)/tmp pip install requests requests-oauthlib
Downloading/unpacking requests
  Downloading requests-2.2.1-py2.py3-none-any.whl (625kB): 625kB downloaded
Downloading/unpacking requests-oauthlib
  Downloading requests-oauthlib-0.4.0.tar.gz
  Running setup.py (path:/tmp/ENV/build/requests-oauthlib/setup.py) egg_info for package requests-oauthlib

Downloading/unpacking oauthlib>=0.4.2 (from requests-oauthlib)
  Downloading oauthlib-0.6.1.tar.gz (96kB): 96kB downloaded
  Running setup.py (path:/tmp/ENV/build/oauthlib/setup.py) egg_info for package oauthlib

Installing collected packages: requests, requests-oauthlib, oauthlib
  Running setup.py install for requests-oauthlib

  Running setup.py install for oauthlib

Successfully installed requests requests-oauthlib oauthlib
Cleaning up...
(ENV)/tmp python
Python 2.7.6 (default, Feb 15 2014, 23:06:13) 
[GCC 4.8.2 20140206 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from requests_oauthlib import OAuth1Session
>>> request_token_url = 'https://api.twitter.com/oauth/request_token'
>>> client_key = 'ident'
>>> client_secret = 'secret'
>>> oauth = OAuth1Session(client_key, client_secret=client_secret)
>>> fetch_response = oauth.fetch_request_token(request_token_url)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/ENV/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 195, in fetch_request_token
    token = self._fetch_token(url)
  File "/tmp/ENV/lib/python2.7/site-packages/requests_oauthlib/oauth1_session.py", line 264, in _fetch_token
    token = dict(urldecode(self.post(url).text))
  File "/tmp/ENV/lib/python2.7/site-packages/oauthlib/common.py", line 135, in urldecode
    raise ValueError('Not a valid urlencoded string.')
ValueError: Not a valid urlencoded string.
>>> 

from requests-oauthlib.

brunsgaard avatar brunsgaard commented on July 24, 2024

okay, the problem is that twitter answers with the string

"Failed to validate oauth signature and token"

and thus https://github.com/idan/oauthlib/blob/master/oauthlib/common.py#L135 raises the error.

Do you guys think it would be an idea to suggest a change to L135, so that the user gets some more information? A suggestion could look like this

raise ValueError('\"{}\" is not a valid urlencoded string.'.format(query))

or du you think it is a bad idea? In some situations it could result in very verbose output.

from requests-oauthlib.

Lukasa avatar Lukasa commented on July 24, 2024

That verbosity does seem like it'd be a problem.

from requests-oauthlib.

ib-lundgren avatar ib-lundgren commented on July 24, 2024

Fix is in the pipeline and should be sorted over the next week. Both a more detailed error message as well as better handling of denied/incorrectly formatted token responses

from requests-oauthlib.

ib-lundgren avatar ib-lundgren commented on July 24, 2024

This error message has got a nice revamp in oauthlib 0.6.2 now and some extra logic has been added to requests-oauthlib to add even more detail to these errors. See #124 for more detail :)

from requests-oauthlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.