Proxy Authentication

181 views
Skip to first unread message

whitemice

unread,
Dec 8, 2009, 9:27:59 AM12/8/09
to Twython Talk
Twython (via urllib?) seems to auto-detect my networks proxy server,
but I need to provide authentication information for the proxy. I've
searched around but found no examples on how to make twython
authenticate to the proxy. [I have confirmed the requests are hitting
the proxy].

I'd also like to be able to manually specify the proxy in some cases,
vs. using the auto-detect.

Ryan McGrath

unread,
Dec 8, 2009, 1:01:57 PM12/8/09
to Twython Talk
What kind of authentication does the proxy require? I'll admit I don't
quite have a full understanding of your situation, but if you could
explain it a little more in depth, I'd be happy to fix both issues for
you.

- Ryan

Adam Tauno Williams

unread,
Dec 8, 2009, 1:07:27 PM12/8/09
to twytho...@googlegroups.com
On Tue, 2009-12-08 at 10:01 -0800, Ryan McGrath wrote:
> What kind of authentication does the proxy require? I'll admit I don't
> quite have a full understanding of your situation, but if you could
> explain it a little more in depth, I'd be happy to fix both issues for
> you.

Proxy (squid) will accept either Basic or NTLM authentication; in this
case Basic seems like the more reasonable [and cross-platform] choice.

Adam Tauno Williams

unread,
Dec 8, 2009, 1:08:07 PM12/8/09
to twytho...@googlegroups.com
On Tue, 2009-12-08 at 10:01 -0800, Ryan McGrath wrote:
> What kind of authentication does the proxy require? I'll admit I don't
> quite have a full understanding of your situation, but if you could
> explain it a little more in depth, I'd be happy to fix both issues for
> you.

Proxy (squid) will accept either Basic or NTLM authentication; in this
case Basic seems like the more reasonable [and cross-platform] choice.

Ryan McGrath

unread,
Dec 8, 2009, 1:10:09 PM12/8/09
to Twython Talk
Hmm, alright, I'll look into adding some configuration options for it
once I get a moment, traveling the next two days.

- Ryan

On Dec 8, 10:07 am, Adam Tauno Williams <awill...@whitemice.org>
wrote:

Ryan McGrath

unread,
Dec 10, 2009, 3:19:50 AM12/10/09
to Twython Talk
Alright, I committed some work that should hopefully take care of your
Proxy woes.

http://github.com/ryanmcgrath/twython/commit/f82702e70643621c0a82ed74e94a912e2b04115c

Basically, pass an object like the following to the setup method. I've
not been able to test this thoroughly yet, so any tests you can do
would be appreciated. Feel free to file bugs on the Github project.

-------------------------------------------------------------------------------

import twython

proxyobj = {
"username": "fjnfsjdnfjd",
"password": "fjnfjsjdfnjd",
"host": "http://fjanfjasnfjjfnajsdfasd.com",
"port": 87
}

lol = twython.setup("username", "password", proxy = proxyobj)

-------------------------------------------------------------------------------

On Dec 8, 1:08 pm, Adam Tauno Williams <awill...@opengroupware.us>
wrote:

Adam Tauno Williams

unread,
Dec 15, 2009, 6:39:53 AM12/15/09
to twytho...@googlegroups.com
On Thu, 2009-12-10 at 00:19 -0800, Ryan McGrath wrote:
> Alright, I committed some work that should hopefully take care of your
> Proxy woes.
> http://github.com/ryanmcgrath/twython/commit/f82702e70643621c0a82ed74e94a912e2b04115c
> Basically, pass an object like the following to the setup method. I've
> not been able to test this thoroughly yet, so any tests you can do
> would be appreciated. Feel free to file bugs on the Github project.
> -------------------------------------------------------------------------------
> import twython
> proxyobj = {
> "username": "fjnfsjdnfjd",
> "password": "fjnfjsjdfnjd",
> "host": "http://fjanfjasnfjjfnajsdfasd.com",
> "port": 87
> }
> lol = twython.setup("username", "password", proxy = proxyobj)
> -------------------------------------------------------------------------------

This looks good, but I think there might be a problem with the egg.

git clone git://github.com/ryanmcgrath/twython.git
cd twython
python setup.py build
sudo python setup.py install

Run "python" from a different directory....

awilliam@linux-m3mt:~> python
Python 2.6.2 (r262:71600, Oct 24 2009, 03:16:31)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twython
>>> x = twython.setup()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setup'
>>> dir(twython)
['__builtins__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__']
>>>

If I do it from the twython source directory it works:

awilliam@linux-m3mt:~/Desktop/Downloads/Python/twython> python
Python 2.6.2 (r262:71600, Oct 24 2009, 03:16:31)
[GCC 4.4.1 [gcc-4_4-branch revision 150839]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twython
>>> x = twython.setup()
>>>

It seems like something isn't being packaged properly in the egg; which
I see installed in

awilliam@linux-m3mt:/usr/local/lib/python2.6/site-packages> ls
-l /usr/local/lib/python2.6/site-packages/twython-0.9-py2.6.egg
-rw-r--r-- 1 root root 63723 2009-12-15
06:18 /usr/local/lib/python2.6/site-packages/twython-0.9-py2.6.egg

and was installed there by setup.py

...
removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing twython-0.9-py2.6.egg
Copying twython-0.9-py2.6.egg to /usr/local/lib/python2.6/site-packages
Adding twython 0.9 to easy-install.pth file
....

Ryan McGrath

unread,
Dec 15, 2009, 12:39:04 PM12/15/09
to Twython Talk
Huh, interesting. Others have reported this problem, but I've never
gotten a consistent consensus on what was actually happening.

I'll look into it sometime this week.

- Ryan

On Dec 15, 6:39 am, Adam Tauno Williams <awill...@opengroupware.us>
wrote:
> On Thu, 2009-12-10 at 00:19 -0800, Ryan McGrath wrote:
> > Alright, I committed some work that should hopefully take care of your
> > Proxy woes.
> >http://github.com/ryanmcgrath/twython/commit/f82702e70643621c0a82ed74...
Reply all
Reply to author
Forward
0 new messages