Here is what I did to solve a similar issue - i am pulling the
username and password and such from constants but it can easily be
tied to your own text boxes. in my case we are authenticating to get a
calendar feed (which only needs the Auth token, not SID or LSID).

    private string GetGoogleAuthentication()
    {
        string parameterString = "accountType=GOOGLE&Email=" +
GOOGLE_USERNAME + "&Passwd=" + GOOGLE_PASSWORD + "&source=" +
GOOGLE_SOURCE + "&service=" + GOOGLE_SERVICE;
        WebRequest request = WebRequest.Create(GOOGLE_POSTURI);
        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";

        byte[] parameters = Encoding.ASCII.GetBytes(parameterString);
        Stream os = null;

        try
        {
            request.ContentLength = parameters.Length; // count the
bytes
            os = request.GetRequestStream();
            os.Write(parameters, 0, parameters.Length); // send the
request
        }
        catch (WebException ex)
        {
            lblErrorMessage.Text = ("Error Authenticating To Google: "
+ ex.Message);
        }
        finally
        {
            if (os != null)
            {
                os.Close();
            }
        }

        try
        {
            WebResponse response = request.GetResponse();
            if (response == null)
            {
                return string.Empty;
            }
            StreamReader sr = new StreamReader
(response.GetResponseStream());
            string AuthToken = sr.ReadToEnd().Trim();
            return AuthToken.Substring(AuthToken.LastIndexOf("Auth=",
AuthToken.Length)).Replace("Auth=", ""); //should contain SID=xxx
LSID=xxx and Auth=xxx. we only need Auth.
        }
        catch (WebException ex)
        {
            lblErrorMessage.Text = ("Error Receiving Response From
Google: " + ex.Message);
        }
        return string.Empty;
    }

FYI, according to google's documentation this is not recommended for
web applications (only client applications)

On Feb 12, 9:12 am, anirbanbose <[email protected]> wrote:
> I am creating an Asp.net web application. I decided to use google
> login for the app. But I want my app will have my own login page
> (instead of google login page). I will send the Userid and password to
> google and it will send the authentication token back. Is there any
> way to do that using Google Data API?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" 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/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to