look my code by to acces to contacts.
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Contactos.aspx.cs" Inherits="Contactos" Trace="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="Google.GData.Client" %>
<%@ Import Namespace="Google.GData.Extensions" %>
<%@ Import Namespace="Google.GData.Calendar" %>
<%@ Import Namespace="System.Net" %>
<script runat="server">
void PrintContact() {
Trace.Write("PrintContact", "Token=" + (String)
Session["token"]);
GAuthSubRequestFactory authFactory = new
GAuthSubRequestFactory("cp", "Tigabytes");
authFactory.Token = (String) Session["token"];
// Service ServiceContact = new
Service(authFactory.ApplicationName);
Service ServiceContact = new Service("cp", "prueba-
contactTest-1");
//ServiceContact.setUserCredentials("
ed...@tigabytes.com",
"edwin1148");
ServiceContact.SetAuthenticationToken(authFactory.Token);
// ServiceContact.RequestFactory = authFactory;
Google.GData.Client.FeedQuery query= new FeedQuery();
//query.Uri = new Uri("
http://www.google.com/m8/feeds/contacts/
tga...@edu.tigabytes.com/base");
query.Uri = new Uri("
http://www.google.com/m8/feeds/contacts/
edwin.mondaca%
40gmail.com/base");
try
{
// EventFeed calFeed = servicecontact.Query(query);
AtomFeed calFeed = ServiceContact.Query(query);
if (calFeed.Entries.Count > 0)
{
}
AtomEntry retrievedEntry = calFeed.Entries[0];
foreach (Google.GData.Client.AtomFeed entry in
calFeed.Entries)
{
Response.Write("Event: " + "<br/>");
}
}
catch (GDataRequestException gdre)
{
HttpWebResponse response = (HttpWebResponse)gdre.Response;
//bad auth token, clear session and refresh the page
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
Trace.Write("Printcontact","Error en codigo");
//Session.Clear();
//Response.Redirect(Request.Url.AbsolutePath, true);
}
else
{
Response.Write("Error processing request: " +
gdre.ToString());
}
}
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Test Site</title>
</head>
<body>
<form id="form1" runat="server">
<h1>First Sample Apis'Contact Fuck</h1>
<div>
<%
GotoAuthSubLink.Visible = false;
Trace.Write("main", "Token" + (String)
Request.QueryString["token"]);
if (Request.QueryString["token"] != null)
{
Trace.Write("main", "Token" + (String)
Request.QueryString["token"]);
Session["token"] = Request.QueryString["token"].ToString();
PrintContact();
}
else if (Request.QueryString["token"] != null)
{
String token = Request.QueryString["token"];
// Session["token"] =
AuthSubUtil.exchangeForSessionToken(token, null).ToString();
Session["token"] = token.ToString();
Response.Write("Request.Url.AbsolutePath :" +
Request.Url.AbsolutePath + ":");
//Response.Redirect(Request.Url.AbsolutePath, true);
}
else //no auth data, print link
{
GotoAuthSubLink.Text = "Login to your Google Account";
GotoAuthSubLink.Visible = true;
//GotoAuthSubLink.NavigateUrl =
AuthSubUtil.getRequestUrl(Request.Url.ToString(),"http://
www.google.com/m8/contacts/feeds/",false,true);
GotoAuthSubLink.NavigateUrl = this.txturl.Text;
}
%>
<table>
<tr>
<td style="width: 100px">
</td>
<td style="width: 773px">
<asp:TextBox ID="txturl" runat="server"
Width="1000px">
https://www.google.com/accounts/AuthSubRequest?
scope=http%3A%2F%
2Fwww.google.com%2Fm8%2Ffeeds
%2F&session=1&secure=1&next=
http://www.tigabytes.com/authsub/
contactos.aspx</asp:TextBox></td>
<td style="width: 353px">%2Fauthsub%2Fcontactos.aspx
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 773px">
</td>
<td style="width: 353px">
</td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 773px">
</td>
<td style="width: 353px">
</td>
</tr>
</table>
<asp:HyperLink ID="GotoAuthSubLink" runat="server"/>
</div>
</form>
</body>
</html>