Hello everyone,
Plz plz plz help me.I am having hard time in using google shared contacts api.
I am using .net C#.
below step i am using
after this click i am able to redirect google page where i am giving my user name and password and after htting grant access I am able to get token which i am using to authorized it.
2) in defautl4.aspx page load
if (!IsPostBack)
{
String token = Request.QueryString["token"];
Session["token"] = token;
HttpWebResponse response = null;
string authSubToken = "";
Uri uri = new Uri(sessionUrl);
HttpWebRequest request = WebRequest.Create(uri) as HttpWebRequest;
Session["header"] = formAuthorizationHeader(Session["token"].ToString(), null, uri, "GET");
request.Headers.Add(Session["header"].ToString());
request.Headers.Add("GData-Version: 3.0");
response = request.GetResponse() as HttpWebResponse;
if (response != null)
{
int code = (int)response.StatusCode;
if (code != 200)
{
}
// get the body and parse it
authSubToken = Utilities.ParseValueFormStream(response.GetResponseStream(), GoogleAuthentication.AuthSubToken);
}
Session["newtoken"]= authSubToken;
}
public static string getSessionTokenUrl(string protocol, string domain)
{
return protocol + "://" + domain + "/accounts/AuthSubSessionToken";
}
So here i am getting 200 as status code so i am gussing that I have authorized it sucessfully.
3) after authorizing token i want to retrieve all shared contacts not personal contacts. so i am making another request
HttpWebResponse response = null;
string sessionUrl = getSessionTokenUrlcontact("https", "
www.google.com");
Uri uri = new Uri(sessionUrl);
HttpWebRequest request = HttpWebRequest.Create(uri) as HttpWebRequest;
string header = formAuthorizationHeader(Session["newtoken"].ToString(), null, uri, "GET");
request.Headers.Add(header);
request.ContentType = "application/x-www-form-urlencoded";
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)";
request.Accept = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
request.KeepAlive = true;
request.Method = "GET";
//request.Headers.Add(Session["header"].ToString());
response = request.GetResponse() as HttpWebResponse;
public static string getSessionTokenUrlcontact(string protocol, string domain)
{
}
So here i am getting error some time 403 or sometime unauthorize 401.
if i change it
mydomain.org by default I am getting all personal contacts but i want to retrieve all shared contacts not personal.
Plz plz plz help what i am missing above?
Thanks
Foram