Search code examples
pythongoogle-people-apiapiclient

python people api quit working


I have a python (2.7.10) code based on the "quickstart" example at https://developers.google.com/people/quickstart/python, which reads contacts from a gmail account. It has been running every Sunday for months. On 12/18/16, it failed. The error message and lines leading up to it are:

...
http = credentials.authorize(httplib2.Http())
service = discovery.build('people', 'v1', http=http,
    discoveryServiceUrl='https://people.googleapis.com/$discovery/rest')

results = service.people().connections().list(resourceName='people/me',
    requestMask_includeField='person.names,person.email_addresses',
    pageSize=160).execute()

AttributeError: 'Resource' object has no attribute 'connections'

On entry to this code 'credentials' seems ok, but I am not skilled enough to really know. credentials.invalid is false, which is what the code checks for.

My code did not change. Did something happen to the build/discovery service? Could the credentials have something to do with this?

This is on Windows 7.

Thanks for any thoughts.


Solution

  • Messing around with it, I was able to get it to work with this change:

    service.people().me().connections().list(pageSize=100).execute()
    

    I'm not sure why the code was changed, or why it wasn't documented. I simply dug around calling dir() on each object.