Hi Sergi,

I tried using your code and could successfully authenticate hosted
accounts.
Could you please share some more details of the error you are
receiving from the authentication service?

You could try to get some more details on the error by probably
handling the exceptions around the 'GetResponse' call.

        Dim objresponse As HttpWebResponse = Nothing
        Try
            objresponse = myrequest.GetResponse

        Catch webEx As WebException
            MsgBox(webEx.Message)

        Catch ex As Exception
            MsgBox(ex.Message)

-Anirudh

On May 13, 9:18 pm, Sergi Doutres <[EMAIL PROTECTED]> wrote:
> Dim mail As String = "email"
>         Dim pwd As String = "pwd"
>         Dim encoding As ASCIIEncoding = New ASCIIEncoding
>         Dim postdata As String = ""
>         postdata = postdata & "accountType=HOSTED"
>         postdata = postdata & "&Email=" & Server.UrlEncode(mail)
>         postdata = postdata & "&Passwd=" & Server.UrlEncode(pwd)
>         postdata = postdata & "&service=apps"
>         Dim data As Byte() = encoding.GetBytes(postdata)
>
>         Dim myrequest As HttpWebRequest =
> HttpWebRequest.Create("https://www.google.com/accounts/ClientLogin";)
>         myrequest.Method = "POST"
>         myrequest.ContentType = "application/x-www-form-urlencoded"
>         myrequest.ContentLength = data.Length
>         Dim newstream As Stream = myrequest.GetRequestStream()
>         Dim myWriter As New StreamWriter(myrequest.GetRequestStream())
>
>         Try
>             myWriter.Write(postdata)
>         Catch ex As Exception
>             Response.Write(Err.Description)
>         Finally
>             myWriter.Close()
>         End Try
>
>         Dim objresponse As HttpWebResponse = myrequest.GetResponse
>         Dim sr As StreamReader = New
> StreamReader(objresponse.GetResponseStream)
>         Dim resultat As String = Server.UrlDecode(sr.ReadToEnd)
>
>         Dim pos As Integer = InStr(resultat, "Auth=")
>         resultat = resultat.Substring(pos + 4)
>         sr.Close()
>
>         return (resultat)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps APIs" 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-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to