0

Does any one have a working example of getting google contact via AuthSub in c#

I have tried this url , but i was not able to complete it.

vamsivanka
  • 792
  • 7
  • 16
  • 36

2 Answers2

0

Here is a piece of code from one of my projects:

    public class GoogleContactsProvider : IContactProvider
{
    #region IContactProvider Members

    /// <summary>
    /// Gets the contacts list form the contact provider.
    /// </summary>
    /// <returns></returns>
    public EntityCollection<IContactItem> GetContactsList()
    {
        EntityCollection<IContactItem> collection = new EntityCollection<IContactItem>();

        // Setup the contacts request (autopage true returns all contacts)
        RequestSettings requestSettings = new RequestSettings("AgileMe", UserName, Password);
        requestSettings.AutoPaging = true;
        ContactsRequest contactsRequest = new ContactsRequest(requestSettings);

        // Get the feed
        Feed<Contact> feed = contactsRequest.GetContacts();

        // create our collection by looping through the feed
        foreach (Contact contact in feed.Entries)
        {
            GoogleContactItem newContact = new GoogleContactItem();
            newContact.Name = contact.PrimaryEmail.Address;
            newContact.Summary = contact.Summary;

            collection.Add(newContact);
        }

        return collection;
    }

    /// <summary>
    /// Gets or sets the name of the user for the contact provider.
    /// </summary>
    /// <value>The name of the user.</value>
    public string UserName { get; set; }

    /// <summary>
    /// Gets or sets the password for the contact provider.
    /// </summary>
    /// <value>The password.</value>
    public string Password { get; set; }

    #endregion
}

EntityCollection is a wrapper around a simple List and GoogleContactItem is a wrapper around the retrieved information.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Flawless
  • 127
  • 7
  • @Perry, I am trying a similar one to stackoverflow login, where i will be redirect to gmail to enter password, but here i am using to get the Address book. Thanks – vamsivanka Apr 15 '11 at 14:49
  • Hey, I am not sure I this was your answer or if you try to do something else? Can you explain further? – Flawless Apr 15 '11 at 21:37
  • What is GoogleContactItem, IContactProvider, .. ? – Kiquenet Dec 26 '13 at 14:13
0

I found this example so simple. link And it works great.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
vamsivanka
  • 792
  • 7
  • 16
  • 36