I am trying to get the user profiles feed from my Google Apps
for business domain. I have been able to poll contacts and docs for users,
but anytime I try to get the profiles feed, I end up getting 401 with
Reason Authorization required. I am using 2 legged Oauth, here is my code:
import atom
import gdata.auth
import gdata.contacts
import gdata.contacts.client
import gdata.contacts.service
import gdata.gauth
CONSUMER_KEY = 'domain.com'
CONSUMER_SECRET = 'keythatissecret'
SIG_METHOD = gdata.auth.OAuthSignatureMethod.HMAC_SHA1
requestor_id = 'admin_at_domain.com'
# Contacts Data API
============================================================
gd_client = gdata.contacts.service.ContactsService(source='blah')
gd_client.auth_token = gdata.gauth.TwoLeggedOAuthHmacToken(
CONSUMER_KEY, CONSUMER_SECRET, requestor_id)
def PrintFeed(feed):
for i, entry in enumerate(feed.entry):
print '\n%s %s' % (i+1, entry.title.text)
max_results = raw_input(
'Enter max return: ')
feed_uri = gd_client.GetFeedUri('profiles')
query = gdata.contacts.service.ContactsQuery(feed_uri)
print(feed_uri)
query.max_results = max_results
#query.orderby='title'
feed = gd_client.GetContactsFeed(query.ToUri())
# Use the print feed method defined above.
PrintFeed(feed)
print(feed_uri)
#print feed
f = open('c:\\python27\\junk.xml', 'w')
f.write(str(feed))
f.close()
And I get the status 401 reason authorization required response. not sure
what else I need, thank you in advance for your help.
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html