What possible ways to import google contacts using python and oauth2.0 exists?
We successfully got credentials, and our application requests access
Final solution was relatively easy.
Step 1 Obtain oauth2.0 token. It's pretty documented in official docs: http://code.google.com/p/google-api-python-client/wiki/OAuth2
Step 2 Now we have token, but can not discover contacts API. But you can find, that in oauth2.0 playground you can import contacts. https://code.google.com/oauthplayground/
You can find, that you have access token in credentials, obtained in Step 1.
To access contacts api you must add to headers following param 'Authorization':'OAuth %s' % access_token
Step 3 Now you must pass to google library token, that will be compatible with oauth1.0 token. It can be done by following code:
from atom.http import ProxiedHttpClient #Google contacts use this client
class OAuth2Token(object):
def __init__(self, access_token):
self.access_token=access_token
def perform_request(self, *args, **kwargs):
url = 'http://www.google.com/m8/feeds/contacts/default/full'
http = ProxiedHttpClient()
return http.request(
'GET',
url,
headers={
'Authorization':'OAuth %s' % self.access_token
}
)
google = gdata.contacts.service.ContactsService(source='appname')
google.current_token = OAuth2Token(oauth2creds.access_token)
feed = google.GetContactsFeed()