kulpa / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Refreshing token behind proxy #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Setting an http object with proxy HTTP settings
2. Getting the token/credentials for the 1st time and passing the http object 
as parameter to the run method (issue 91) --> OK
3. Refreshing the token later -> KO

When refreshing, the http object is not used, the connection is done directly 
without using the http object with proxy settings.

Original issue reported on code.google.com by pschi...@gmail.com on 16 Feb 2012 at 7:44

GoogleCodeExporter commented 9 years ago
The refresh is done using the http object that the Credentials was applied to, 
so it should have the proxy settings:

  http://code.google.com/p/google-api-python-client/source/browse/oauth2client/client.py#398

Can you supply a sample which recreates this issue?

Original comment by jcgregorio@google.com on 23 Feb 2012 at 6:00

GoogleCodeExporter commented 9 years ago

Original comment by jcgregorio@google.com on 23 Feb 2012 at 6:02

GoogleCodeExporter commented 9 years ago
Well this issue happens some hour later when I relaunch the script :
1. First time you get the token with the http object (with proxy settings) -> OK
2. 5 min later, you launch again the scripts -> still work
3. You wait 1 or 2 hours, launch the scripts -> KO

Any piece of code should recreates the issue.

Here is the exception error :

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    main()
  File "main.py", line 7, in main
    GoogleCal.main()
  File "Y:\pythonPort\OutlookToGcal\GoogleCal.py", line 289, in main
    calendar_list = service.calendarList().list().execute()
  File "Y:\pythonPort\App\lib\site-packages\google_api_python_client-1.0beta7-py
2.7.egg\apiclient\http.py", line 384, in execute
    headers=self.headers)
  File "Y:\pythonPort\App\lib\site-packages\google_api_python_client-1.0beta7-py
2.7.egg\oauth2client\client.py", line 398, in new_request
    self._refresh(request_orig)
  File "Y:\pythonPort\App\lib\site-packages\google_api_python_client-1.0beta7-py
2.7.egg\oauth2client\client.py", line 556, in _refresh
    self._do_refresh_request(http_request)
  File "Y:\pythonPort\App\lib\site-packages\google_api_python_client-1.0beta7-py
2.7.egg\oauth2client\client.py", line 575, in _do_refresh_request
    self.token_uri, method='POST', body=body, headers=headers)
  File "Y:\pythonPort\App\lib\site-packages\httplib2\__init__.py", line 1476, in
 request
    (response, content) = self._request(conn, authority, uri, request_uri, metho
d, body, headers, redirections, cachekey)
  File "Y:\pythonPort\App\lib\site-packages\httplib2\__init__.py", line 1228, in
 _request
    (response, content) = self._conn_request(conn, request_uri, method, body, he
aders)
  File "Y:\pythonPort\App\lib\site-packages\httplib2\__init__.py", line 1164, in
 _conn_request
    conn.connect()
  File "Y:\pythonPort\App\lib\site-packages\httplib2\__init__.py", line 917, in
connect
    sock.connect((self.host, self.port))
  File "Y:\pythonPort\App\lib\site-packages\httplib2\socks.py", line 403, in con
nect
    raise GeneralProxyError((5, _generalerrors[5]))
httplib2.socks.GeneralProxyError: (5, 'bad input')

Original comment by pschi...@gmail.com on 24 Feb 2012 at 12:34

GoogleCodeExporter commented 9 years ago
I am running into the same problem. 

The problem is that on the token refresh the hostname is passed in as 
u"accounts.google.com" 
which does not pass the invariant check for httplib2.socks.connect() on line 
402 of python2/httplib2/socks.py 

Which was fixed in: 
http://code.google.com/p/httplib2/source/detail?r=9ae3ddb265d4ec127e5458e1176420
542ccf63ab

Original comment by j...@hyves.nl on 29 Feb 2012 at 8:49

GoogleCodeExporter commented 9 years ago
httplib2 0.7.3 was just released and should fix this issue.

Original comment by jcgregorio@google.com on 2 Mar 2012 at 7:34