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 1 ) create link which redirects to :https://www.google.com/accounts/AuthSubRequest?scope=https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2F&session=1&secure=0&hd=mydomain.org&next=http%3A%2F%2Flocalhost:53061/Googlecontacts/Default4.aspx 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 = ""; string sessionUrl = getSessionTokenUrl("https", "www.google.com"); 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 = "https://www.google.com/m8/feeds/contacts/watershedhealth/full"; 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.Host = "www.google.com"; 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) { return protocol + "://" + domain + "/m8/feeds/contacts/mydomain.org/full"; } 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. I am following https://developers.google.com/google-apps/domain-shared-contacts/ . Plz plz plz help what i am missing above? Thanks Foram -- You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-apps-mgmt-apis/-/pmd_t7QG0zMJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.
