fujisakifujita / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

HTTP Error 401 every time. #161

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. install simplejson and python-twitter (...duh)
2. run the following:
     api = twitter.Api(username = '[correct uname', password = '[correct... pwd]')
     api.PostUpdate('word')
3. receive HTTPError: HTTP Error 401: Unauthorized

What is the expected output? What do you see instead?
I was expecting a new tweet on the account, consisting of "word". Instead, I 
get that 401 error every single time. This first occurred about a week and a 
half ago in a program that had been working fine for the preceding couple of 
months.

What version of the product are you using? On what operating system?
Python 2.4 on XP, simplejson 2.0.9, python-twitter 0.5.
Then switched to simplejson 2.1.1, python-twitter 0.6, in case there was a 
problem with one of the older versions.

Please provide any additional information below.
I suspect this is twitters problem rather than python-twitter's. But any light 
(at all) that could be shed on it would help.

Original issue reported on code.google.com by pete.dou...@gmail.com on 14 Sep 2010 at 10:03

GoogleCodeExporter commented 8 years ago
A bit more detail: the full error response I get is:

File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", 
line 307, in RunScript
    debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File "C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File "C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 631, in run
    exec cmd in globals, locals
  File "C:\Documents and Settings\Peter Doughty\My Documents\Work\Python Scripts\temp.py", line 15, in ?
    api.PostUpdate('word')
  File "build\bdist.win32\egg\twitter.py", line 1494, in PostUpdate
  File "build\bdist.win32\egg\twitter.py", line 2018, in _FetchUrl
  File "C:\Python24\lib\urllib2.py", line 364, in open
    response = meth(req, response)
  File "C:\Python24\lib\urllib2.py", line 471, in http_response
    response = self.parent.error(
  File "C:\Python24\lib\urllib2.py", line 402, in error
    return self._call_chain(*args)
  File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "C:\Python24\lib\urllib2.py", line 480, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

I have checked and rechecked the username and password.

Original comment by pete.dou...@gmail.com on 14 Sep 2010 at 10:07

GoogleCodeExporter commented 8 years ago
Hi Pete,
You are right that the problem is with twitter rather than python-twitter for 
the most part. Twitter has changed its authorization method from "username and 
password" to using oauth which requires a key and a secret. They've phased out 
the old method and python-twitter hasn't made a stable release utilizing this 
method. You can use http://code.google.com/p/oauth-python-twitter/ instead 
while waiting for the new python-twitter release.

Original comment by MrFuzz...@gmail.com on 14 Sep 2010 at 6:33

GoogleCodeExporter commented 8 years ago
Please try this with the very latest code double-checking that 1) you are using 
oAuth key/secret values and that the simplegeo fork of python-oauth2 is used.  
I had made a mistake in the docs pointing everyone to another oauth2 lib.

Original comment by bear42 on 16 Oct 2010 at 7:48

GoogleCodeExporter commented 8 years ago
so just instead of username/password we use the key/secret ?

Original comment by j.siemia...@gmail.com on 18 Oct 2010 at 1:00

GoogleCodeExporter commented 8 years ago
yes - the latest code has been updated to use those parameter names now.

Original comment by bear42 on 18 Oct 2010 at 5:35

GoogleCodeExporter commented 8 years ago
pretty sure you forgot to upload it - because with the version i downloaded it 
does not work - at least not python-twitter. will try oauth-twitter from you 
guys, but this is kinda hard to get around with if it is a distributed all over 
the place. should have a notice on the start page, something redirecting, if 
you want everyone to use oauth

Original comment by WSchla...@gmail.com on 23 Oct 2010 at 6:59

GoogleCodeExporter commented 8 years ago
addendum: perhaps an update to you examples on the front page might be nice?

Original comment by WSchla...@gmail.com on 23 Oct 2010 at 7:00

GoogleCodeExporter commented 8 years ago
i have been getting the same issues again and again.... has the changes been 
committed to use the token key and password

Original comment by mukherje...@gmail.com on 26 Oct 2010 at 1:13

GoogleCodeExporter commented 8 years ago
I installed this yesterday and gave up on getting auth to work. The examples on 
the web page or the ones included with the packages don't work. There are no 
good examples for using oauth in oauth-twitter either. I gave up and used 
tweepy 
http://jeffmiller.github.com/2010/05/31/twitter-from-the-command-line-in-python-
using-oauth

When will there be a new release of python-twitter to fix this?

Original comment by dom...@gmail.com on 5 Nov 2010 at 5:25

GoogleCodeExporter commented 8 years ago
I really don't understand why you all are saying that python-twitter doesn't 
support oauth.  Sure it may only be in the trunk right now, but you can follow 
the notes in the README which says that Twitter now only supports oAuth and the 
Twitter docs about oAuth describe how to get your consumer_key and 
consumer_secret.

Once you have those you then run the get_access_token.py script to generate the 
rest of the data.

Yea, Twitter and oAuth are complicated, heck it took me almost a week to get 
python-twitter to work with the python oauth lib, but it does work.

I have been correcting the odd doc locations that I wasn't aware of as I find 
(or am told about them) - so if you find some let me know.

Original comment by bear42 on 5 Nov 2010 at 5:47

GoogleCodeExporter commented 8 years ago
I didn't say it doesn't support it. I was just asking when there will be a new 
release. I didn't know how to use trunk or oauth-twitter or python-oauth2.
The example tweet.py with the latest package of python-twitter is wrong. I 
guess it is because 0.6 is from July 2009. 

Original comment by dom...@gmail.com on 5 Nov 2010 at 7:09

GoogleCodeExporter commented 8 years ago
ahh - then I need to apologize as I thought you were using the trunk source.

yes, getting a release has been at the top of my mind, just need to find some 
focus time.

again, sorry for jumping all over ya for the wrong thing! doh!

Original comment by bear42 on 5 Nov 2010 at 8:04