Search code examples
pythongoogle-app-engineoauth-2.0google-contacts-api

python + appengine + oauth2 + google contacts api


So I am verily confused. Mainly about the "right" way to have a web app that runs on python app engine that can talk to the user to get them to accept via oauth2 permissions so that my app engine app can read/write to their contacts db. I have something along the lines of this (which is based on the app engine examples on http://code.google.com/p/google-api-python-client/ and specifically http://code.google.com/p/google-api-python-client/source/browse/#hg%2Fsamples%2Fappengine )

I have modified the SCOPES to be

SCOPES = (
          'https://www.google.com/m8/feeds','https://www.googleapis.com/auth/plus.me'
          )

but the issue I get is I that I don't want to run

        http = decorator.http()
        user = service.people().get(userId='me').execute(http=http)

but something like

        http = decorator.http()
        user = service.contacts().get(userId='*').execute(http=http)

However for the life of me I have no idea what to put after the service.... function.. and of course I don't know how to google this as .. well I don't know what term I am googling for.

I have tried modifying the service constructor .. but again I don't know what to put in it.

service = build("plus", "v1", http=http)  ### works for g+
contact_service = build("m8","v3",http=http) ### doesn't work for toffee

I did see this effort here : Retrieving contacts with gdata.contacts.client and oauth2 but would rather go with a "stock google" solution as they tend to maintain those .. (generally)

Ok.. so digging around I found this useful meta-api call:

https://www.googleapis.com/discovery/v1/apis/

which has absolutely no mention of the contact api. Am I to assume that this method isn't suitable?


Solution

  • The current version of the Contacts API (v3) uses the older gdata-python-client library, not the new google-api-python-client. Details for using OAuth 2.0 with the gdata Python APIs can be found in this blog entry. The blog calls the Calendar and Docs client APIs but Contacts should be very similar.