librelist archives

« back to archive

Flask-OAuth Requests Behind Proxies

Flask-OAuth Requests Behind Proxies

From:
Ben Tortora
Date:
2012-06-26 @ 19:06
Hi all,

I have currently started working on a project, but when I am working on 
site, I am behind a HTTP Proxy.

So when using Flask-Oauth to make a request to the Twitter API for 
example, I don't get the data back.

I have had a look at httplib2 which is being used and I don't want to hack
the plugin, and I have an environment variable setup at an OS level to 
call upon, but have no idea how to go about it.

Any help would be appreciated.

Ben

Re: [flask] Flask-OAuth Requests Behind Proxies

From:
Max Countryman
Date:
2012-06-26 @ 19:11
Hi Ben,

Without more details it's hard to diagnose your exact issue. However if 
you're planning to use OAuth you might consider giving rauth[1] a try. 
There's even a Twitter example[2] included. Because rauth is built on 
Requests this may give you slightly better handling of HTTP proxies. 
However that said, I haven't tried this myself.

HTH,


Max

[1] https://github.com/litl/rauth
[2] https://github.com/litl/rauth/blob/master/examples/twitter-timeline.py

On Jun 26, 2012, at 3:06 PM, Ben Tortora wrote:

> Hi all,
> 
> I have currently started working on a project, but when I am working on 
site, I am behind a HTTP Proxy.
> 
> So when using Flask-Oauth to make a request to the Twitter API for 
example, I don't get the data back.
> 
> I have had a look at httplib2 which is being used and I don't want to 
hack the plugin, and I have an environment variable setup at an OS level 
to call upon, but have no idea how to go about it.
> 
> Any help would be appreciated.
> 
> Ben

Re: [flask] Flask-OAuth Requests Behind Proxies

From:
Ib Lundgren
Date:
2012-06-26 @ 19:28
Hi,

Seconding Ben, requests might help. requests also happen to have
experimental but excellent OAuth 1 support built in

https://gist.github.com/2581132 (hmac)
https://gist.github.com/2584789 (rsa)

Cheers,
Ib

On Tue, Jun 26, 2012 at 9:11 PM, Max Countryman <maxc@me.com> wrote:

> Hi Ben,
>
> Without more details it's hard to diagnose your exact issue. However if
> you're planning to use OAuth you might consider giving rauth[1] a try.
> There's even a Twitter example[2] included. Because rauth is built on
> Requests this may give you slightly better handling of HTTP proxies.
> However that said, I haven't tried this myself.
>
> HTH,
>
>
> Max
>
> [1] https://github.com/litl/rauth
> [2] https://github.com/litl/rauth/blob/master/examples/twitter-timeline.py
>
> On Jun 26, 2012, at 3:06 PM, Ben Tortora wrote:
>
> > Hi all,
> >
> > I have currently started working on a project, but when I am working on
> site, I am behind a HTTP Proxy.
> >
> > So when using Flask-Oauth to make a request to the Twitter API for
> example, I don't get the data back.
> >
> > I have had a look at httplib2 which is being used and I don't want to
> hack the plugin, and I have an environment variable setup at an OS level to
> call upon, but have no idea how to go about it.
> >
> > Any help would be appreciated.
> >
> > Ben
>
>

Re: [flask] Flask-OAuth Requests Behind Proxies

From:
Ib Lundgren
Date:
2012-06-26 @ 19:28
Sorry, meant Max,

On Tue, Jun 26, 2012 at 9:28 PM, Ib Lundgren <ib.lundgren@gmail.com> wrote:

> Hi,
>
> Seconding Ben, requests might help. requests also happen to have
> experimental but excellent OAuth 1 support built in
>
> https://gist.github.com/2581132 (hmac)
> https://gist.github.com/2584789 (rsa)
>
> Cheers,
> Ib
>
>
> On Tue, Jun 26, 2012 at 9:11 PM, Max Countryman <maxc@me.com> wrote:
>
>> Hi Ben,
>>
>> Without more details it's hard to diagnose your exact issue. However if
>> you're planning to use OAuth you might consider giving rauth[1] a try.
>> There's even a Twitter example[2] included. Because rauth is built on
>> Requests this may give you slightly better handling of HTTP proxies.
>> However that said, I haven't tried this myself.
>>
>> HTH,
>>
>>
>> Max
>>
>> [1] https://github.com/litl/rauth
>> [2]
>> https://github.com/litl/rauth/blob/master/examples/twitter-timeline.py
>>
>> On Jun 26, 2012, at 3:06 PM, Ben Tortora wrote:
>>
>> > Hi all,
>> >
>> > I have currently started working on a project, but when I am working on
>> site, I am behind a HTTP Proxy.
>> >
>> > So when using Flask-Oauth to make a request to the Twitter API for
>> example, I don't get the data back.
>> >
>> > I have had a look at httplib2 which is being used and I don't want to
>> hack the plugin, and I have an environment variable setup at an OS level to
>> call upon, but have no idea how to go about it.
>> >
>> > Any help would be appreciated.
>> >
>> > Ben
>>
>>
>

Re: [flask] Flask-OAuth Requests Behind Proxies

From:
Ben Tortora
Date:
2012-06-26 @ 22:33
Hi all,

Thanks again for the responses. Sorry for the delay but I am Australian so
there will be a bit of the lag.

At my workstation on site and this is what comes back after attempting the
request:

Traceback (most recent call last):
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1518, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1506, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1504, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1264, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1262, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Projects\social\env\lib\site-packages\flask\app.py", line
1248, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Projects\social\social.py", line 110, in login
    return twitter.authorize(callback=url_for('oauth_authorized',
next=request.args.get('next') or request.referrer or None))
  File "C:\Projects\social\env\lib\site-packages\flaskext\oauth.py",
line 303, in authorize
    token = self.generate_request_token(callback)[0]
  File "C:\Projects\social\env\lib\site-packages\flaskext\oauth.py",
line 272, in generate_request_token
    self.request_token_params)
  File "C:\Projects\social\env\lib\site-packages\flaskext\oauth.py",
line 107, in request_new_token
    body=body, headers=headers)
  File "C:\Projects\social\env\lib\site-packages\httplib2\__init__.py",
line 1544, in request
    (response, content) = self._request(conn, authority, uri,
request_uri, method, body, headers, redirections, cachekey)
  File "C:\Projects\social\env\lib\site-packages\httplib2\__init__.py",
line 1294, in _request
    (response, content) = self._conn_request(conn, request_uri,
method, body, headers)
  File "C:\Projects\social\env\lib\site-packages\httplib2\__init__.py",
line 1268, in _conn_request
    conn.connect()
  File "C:\Projects\social\env\lib\site-packages\httplib2\__init__.py",
line 890, in connect
    raise socket.error, msg
error: [Errno 10060] A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond


Hope that helps! If you need more information to help me, please ask.

Once I have it all sorted I will either submit some changes to Flask-OAuth
or blog the experience with solution.

Thanks,

Ben

On 27 June 2012 05:28, Ib Lundgren <ib.lundgren@gmail.com> wrote:

> Sorry, meant Max,
>
>
> On Tue, Jun 26, 2012 at 9:28 PM, Ib Lundgren <ib.lundgren@gmail.com>wrote:
>
>> Hi,
>>
>> Seconding Ben, requests might help. requests also happen to have
>> experimental but excellent OAuth 1 support built in
>>
>> https://gist.github.com/2581132 (hmac)
>> https://gist.github.com/2584789 (rsa)
>>
>> Cheers,
>> Ib
>>
>>
>> On Tue, Jun 26, 2012 at 9:11 PM, Max Countryman <maxc@me.com> wrote:
>>
>>> Hi Ben,
>>>
>>> Without more details it's hard to diagnose your exact issue. However if
>>> you're planning to use OAuth you might consider giving rauth[1] a try.
>>> There's even a Twitter example[2] included. Because rauth is built on
>>> Requests this may give you slightly better handling of HTTP proxies.
>>> However that said, I haven't tried this myself.
>>>
>>> HTH,
>>>
>>>
>>> Max
>>>
>>> [1] https://github.com/litl/rauth
>>> [2]
>>> https://github.com/litl/rauth/blob/master/examples/twitter-timeline.py
>>>
>>> On Jun 26, 2012, at 3:06 PM, Ben Tortora wrote:
>>>
>>> > Hi all,
>>> >
>>> > I have currently started working on a project, but when I am working
>>> on site, I am behind a HTTP Proxy.
>>> >
>>> > So when using Flask-Oauth to make a request to the Twitter API for
>>> example, I don't get the data back.
>>> >
>>> > I have had a look at httplib2 which is being used and I don't want to
>>> hack the plugin, and I have an environment variable setup at an OS level to
>>> call upon, but have no idea how to go about it.
>>> >
>>> > Any help would be appreciated.
>>> >
>>> > Ben
>>>
>>>
>>
>