Okay, I followed the answer here: Is it possible to use "Domain-wide Delegation of Authority" with gdata-python-client?
However when I run my test I get this:
oauth2client.client.AccessTokenRefreshError: access_denied
Here's my code:
class OAuthToken():
def __init__(self, creds):
self.creds = creds
def modify_request(self, req):
if self.creds.access_token_expired or not self.creds.access_token:
self.creds.refresh(httplib2.Http())
self.creds.apply(req.headers)
def ListContacts(username):
file = open('privatekey.pem','rb')
text = file.read()
file.close()
credentials = SignedJwtAssertionCredentials('somelongnumber@developer.gserviceaccount.com',\
text,\
scope=['http://www.google.com/m8/feeds/'],\
prn=username+'@mycompany.com')
gdclient = gdata.contacts.client.ContactsClient(source='mycompany.com')
gdclient.auth_token = OAuthToken(credentials)
feed = gdclient.GetContacts()
All of my other OAuth2 stuff works, it's just the contacts that are causing me grief, so I think I have the API & credentials set up correctly.
I did add https://www.google.com/m8/feeds/ to my "One or More API Scopes" in the API security, but that doesn't seem to have helped.
What might I be missing?