srbodkhe / google-shared-contacts-client

Automatically exported from code.google.com/p/google-shared-contacts-client
Apache License 2.0
0 stars 0 forks source link

Can't get shared-contacts.py to work through a proxy server #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. behind proxy server (BlueCoat) set to not autenticate
2. set http_proxy=http://fqdn:80/ and set https_proxy=http://fqdn:80/
3. shared-contacts.py -a username@domain -p pass -e out.csv

What is the expected output? What do you see instead?

C:\google\google-shared-contacts-client-1.0.1\google-shared-contacts-client>shar
ed_contacts.py
-a user@domain -p pass -e out.csv
Export as CSV to: out.csv
Domain: ddd
Administrator: uuu
Using password passed to --password
### Exporting contacts to CSV file: out.csv
Retrieving contacts... (0 retrieved so far)
Traceback (most recent call last):
  File
"C:\google\google-shared-contacts-client-1.0.1\google-shared-contacts-client\sha
red_contacts.py",
line 796, in <module>
    main()
  File
"C:\google\google-shared-contacts-client-1.0.1\google-shared-contacts-client\sha
red_contacts.py",
line 791, in main
    contacts_manager.ExportMsOutlookCsv(contact_entries, export_csv_file)
  File
"C:\google\google-shared-contacts-client-1.0.1\google-shared-contacts-client\sha
red_contacts.py",
line 401, in ExportMsOutlookCsv
    contact_entries))
  File "c:\python25\lib\csv.py", line 131, in writerows
    for rowdict in rowdicts:
  File
"C:\google\google-shared-contacts-client-1.0.1\google-shared-contacts-client\sha
red_contacts.py",
line 213, in GetAllContacts
    feed = self.contacts_service.GetContactsFeed(feed_url)
  File "C:\Python25\Lib\site-packages\gdata\contacts\service.py", line 95,
in GetContactsFeed
    return self.Get(uri, converter=gdata.contacts.ContactsFeedFromString)
  File "C:\Python25\Lib\site-packages\gdata\service.py", line 1025, in Get
    'reason': server_response.reason, 'body': result_body}
gdata.service.RequestError: {'status': 400, 'body': 'Invalid value for
Cache-Control option &#39;max-stale&#39;', 'reason': 'Bad Request'}

What version of the product are you using? On what operating system?
windows server 2003 R2 SP2
python 2.5.4 or python 2.4.4
gdata 1.3.1
shared-contacts 1.0.1

Please provide any additional information below.

python 2.6 gives a different error behind proxy. I can run the same command
on a Windows XP system at home (not behind the proxy)

Original issue reported on code.google.com by edward.q...@gmail.com on 10 Jun 2009 at 7:09

GoogleCodeExporter commented 9 years ago
To use the Python script for shared contacts behind a proxy, you would need to 
edit
the file 'shared_contacts.py' and include the following with your network 
settings:

import os

os.environ['http_proxy'] = 'http://192.168.1.2:1234' 
os.environ['https_proxy'] = 'https://192.168.1.2:1234' 
os.environ['proxy-username'] = 'user' 
os.environ['proxy-password'] = 'pass' 

Original comment by julian10...@gmail.com on 11 Jun 2009 at 9:47

GoogleCodeExporter commented 9 years ago
FYI, passing the no-cache option with the connection resolves this for us 
(NOTE: we
are using BlueCoat proxy appliances).

Here is the response from Google with the details:

Hi Edward,

I think your proxy server is sending an invalid value for the header
'max-stale' to the Google server, what kind of proxy server are you using?

Maybe you could try to set 'no-cache' or send a valid value for
'max-stale', you can add additional headers on the contacts_service class
constructor, for example:

 contacts_service = gdata.contacts.service.ContactsService(
     email = admin_email,
     password = admin_password,
     account_type = 'HOSTED',
     contact_list = domain,
     source = 'shared_contacts',
     additional_headers = {'Cache-Control':'no-cache'},
   )

Original comment by edward.q...@gmail.com on 12 Jun 2009 at 1:20

GoogleCodeExporter commented 9 years ago
For the next version can the no-cache be made a configurable option for this 
script
(command line switch or env variable or config file or something)?
Thanks,
Ed

Original comment by edward.q...@gmail.com on 12 Jun 2009 at 1:22

GoogleCodeExporter commented 9 years ago
I've another error when execute the script, pls advise. Thx~ The errors are:

C:\GoogleApps\google-shared-contacts-client>python shared_contacts.py
--admin=<admin-user>@<domain-name> --export=export-file.csv
Export as CSV to: export-file.csv
Domain: <domain-name>
Administrator: <admin-user>@<domain-name>
Password of <admin-user>@<domain-name>:
Traceback (most recent call last):
  File "shared_contacts.py", line 801, in <module>
    main()
  File "shared_contacts.py", line 775, in main
    contacts_service.ProgrammaticLogin()
  File "C:\Python25\Lib\site-packages\gdata\service.py", line 780, in Programmat
icLogin
    headers={'Content-Type':'application/x-www-form-urlencoded'})
  File "C:\Python25\Lib\site-packages\atom\http.py", line 124, in request
    connection = self._prepare_connection(url, all_headers)
  File "C:\Python25\Lib\site-packages\atom\http.py", line 232, in _prepare_conne
ction
    p_sock.connect((proxy_url.host, int(proxy_url.port)))
  File "<string>", line 1, in connect
socket.gaierror: (11001, 'getaddrinfo failed')

C:\GoogleApps\google-shared-contacts-client>

Original comment by lamtl...@gmail.com on 13 Oct 2009 at 3:58