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.Feed
1.get_AtomFeed() at Google.GData.Client.Feed
1.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?