8
votes

I am using Google Contacts Data Api to get all user contacts following the documentation here https://developers.google.com/google-apps/contacts/v3/

first i used Google Auth to authenticate users to the application using the following code

string authSubUrl = AuthSubUtil.getRequestUrl("http://localhost:62439/ContactImporter/GoogleContacts.aspx", "https://www.google.com/m8/feeds/", true, true);
    Response.Redirect(authSubUrl);

second after user successfully loged in i redirect to GoogleContacts.aspx page with request token provided from Google and then trying to get contacts by the following code

if (!string.IsNullOrEmpty(Request["token"]))
{
    GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cp", "alpha");   
    RequestSettings rs = new Google.GData.Client.RequestSettings("alpha",Request["token"]);
    ContactsRequest cr = new ContactsRequest(rs);

    Feed<Contact> f = cr.GetContacts();

    foreach (Contact entry in f.Entries)
    {
        foreach (EMail email in entry.Emails)
        {
            Response.Write("\n" + email.Address);
        }
    }
}

that code was working from about 4 or 5 days but now its not working and gets me the following error

The remote server returned an error: (401) Unauthorized. at Google.GData.Client.GDataRequest.Execute() at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter) at Google.GData.Client.GDataGAuthRequest.Execute() at Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince, String etag, Int64& contentLength) at Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince) at Google.GData.Client.Service.Query(FeedQuery feedQuery) at Google.GData.Client.Feed1.get_AtomFeed() at Google.GData.Client.Feed1.d__0.MoveNext() at GoogleContacts.Page_Load(Object sender, EventArgs e) in d:\Working Folder\API's\ContactImporter\GoogleContacts.aspx.cs:line 25 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Any suggestions on how to resolve that error?

1
A topic has been started on google forums : here. Maybe google will answer our questions...Max
any final solution with full source code sample working about it ?Kiquenet

1 Answers

2
votes

This will not be the answer that you are looking for, but I can put your mind to rest. There is nothing wrong with your code. Google took down the Contacts API service recently, without notice. Nobody knows if they have made it obsolete or they took it down for some other reason. As of yesterday, they even took the API documentation down. However the link to it is still posted in their list of API's at https://developers.google.com/google-apps/app-apis there is no longer any documentation what-so-ever and no explanation by Google why it was shut down. Hopefully it is not a permanent thing. Google has yet to answer developers on this issue.