I am trying to fetch Google calendar event in the Windows store app
(C#).  As Google library is not compatible with Windows store app,
trying for alternative. Below is my code. I am getting error as below.
Plz help to resolve and fetch Google calendar events .

An error occurred while sending the request. The request was aborted:
Could not create SSL/TLS secure channel.
And sometime we get
Response status code does not indicate success: 401 (Authorization
required).

try
            {
                //Calendar event fetching

                var objURLAuth = string.Format("http://www.google.com/
accounts/ClientLogin?service=cl&Email={0}&Passwd={1}",
Uri.EscapeDataString(txtAccount.Text.Trim()),
Uri.EscapeDataString(txtPassword.Password.Trim()));
                HttpClient objHttpClient = new HttpClient();
                HttpResponseMessage objResponseAuth;
                objResponseAuth = await
objHttpClient.GetAsync(objURLAuth);

                string sResponseAuthText = await
objResponseAuth.Content.ReadAsStringAsync();
                if (sResponseAuthText != "Error=BadAuthentication\n")
                {
                    //string SID =
sResponseAuthText.Substring((sResponseAuthText.IndexOf("SID=") + 4),
(sResponseAuthText.IndexOf("\n") - 4));//extracting SID
                    string Auth =
sResponseAuthText.Substring((sResponseAuthText.IndexOf("Auth=") + 5),
(sResponseAuthText.Length - (sResponseAuthText.IndexOf("Auth=") + 5))
- 1);//extracting Auth

                    HttpClient objHttpClientzzz;
                    objHttpClientzzz = objHttpClient;

 
objHttpClientzzz.DefaultRequestHeaders.Add("Authorization",
"GoogleLogin auth=" + Auth);
                    HttpResponseMessage ObjCalHttpReponse = await
objHttpClientzzz.GetAsync("https://www.google.com/calendar/feeds/
default/private/full");
                    ObjCalHttpReponse.EnsureSuccessStatusCode();
                    string html = await
ObjCalHttpReponse.Content.ReadAsStringAsync();

                    string sStatusCode =
ObjCalHttpReponse.StatusCode.ToString();

                    string sCalResponseText = await
ObjCalHttpReponse.Content.ReadAsStringAsync();

                    var md = new MessageDialog("Events: " +
sCalResponseText);
                    md.Commands.Add(new UICommand("OK",
(UICommandInvokedHandler) =>
                    {

                    }));
                    md.ShowAsync();
                }

            }
            catch (Exception Ex)
            {
                //if (bIsDebug == true)
                {
                    var md = new MessageDialog("Error: " +
Ex.Message.ToString());
                    md.Commands.Add(new UICommand("OK",
(UICommandInvokedHandler) =>
                    {

                    }));
                    md.ShowAsync();
                }
            }

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
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/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to