tags:

views:

267

answers:

1

Hi friends, I have incorporated ClientLogin into my python application to retrieve contact list of the user , I like to know how to get the name of the user who has logged in.My code to get the names from the contact list of the user is as given below

            gd_client = gdata.contacts.service.ContactsService()
            gd_client.email = yemail
            gd_client.password = ypass
            gd_client.source = 'GoogleInc-ContactsPythonSample-1'
            gd_client.ProgrammaticLogin()
            query = gdata.contacts.service.ContactsQuery()
            query.max_results=150
            feed = gd_client.GetContactsFeed(query.ToUri())

            for i, entry in enumerate(feed.entry):
                    #print '\n%s %s' % (ctr+i+1, entry.title.text)
                    na=entry.title.text
                    names.append(na)

Please help me to know how to get the name of the user who has logged in Thanks ganesh

A: 

Edit: Turns out this is only for iterating through the AppsService which will not help you. I am using GAE so for me the google.appengine.api users class takes care of all the heavy lifting for me. I will keep looking into this.

You might try the following code:

gd_client = gdata.contacts.service.ContactsService()
gd_client.email = yemail
gd_client.password = ypass
gd_client.source = 'GoogleInc-ContactsPythonSample-1'
gd_client.ProgrammaticLogin()
nick_feed = gd_client.RetrieveAllNicknames() 
for nick_entry in nick_feed.entry: 
  print nick_entry.nickname.name 
  print nick_entry.login.user_name 

This should work across all the gdata services. I am going to test it though and I will let you know how it goes. This information was found at this location.

Gabriel