Hi Lane,
I looked at the code which through which the error is propagating and i think
QueryAuthToken(NetworkCredentails) throws this GDataRequestException. The
problem is that the there is no response stream available when this error
occurs.
Should i log the PostData which is being sent for getting the AuthToken ? See
the code below, the highligted bold text is where the error is and the
responseString property of GDataRequestException returns null.
How do i track the error ? I am completely lost
protected string QueryAuthToken(NetworkCredential nc)
{
Tracing.Assert(nc != null, "Do not call QueryAuthToken with no network
credentials");
if (nc == null)
{
throw new System.ArgumentNullException("nc", "No credentials supplied");
}
// Create a new request to the authentication URL.
Uri authHandler = null;
try
{
authHandler = new Uri(this.factory.Handler);
}
catch
{
throw new GDataRequestException("Invalid authentication handler URI given");
}
WebRequest authRequest = WebRequest.Create(authHandler);
string accountType = GoogleAuthentication.AccountType;
if (this.factory.AccountType != null)
{
accountType += this.factory.AccountType;
}
else
{
accountType += GoogleAuthentication.AccountTypeDefault;
}
if (this.factory.Proxy != null)
{
authRequest.Proxy = this.factory.Proxy;
}
HttpWebRequest web = authRequest as HttpWebRequest;
if (web != null)
{
web.KeepAlive = this.factory.KeepAlive;
}
WebResponse authResponse = null;
string authToken = null;
try
{
authRequest.ContentType = HttpFormPost.Encoding;
authRequest.Method = HttpMethods.Post;
ASCIIEncoding encoder = new ASCIIEncoding();
// now enter the data in the stream
string postData = GoogleAuthentication.Email + "=" +
Utilities.UriEncodeReserved(nc.UserName) + "&";
postData += GoogleAuthentication.Password + "=" +
Utilities.UriEncodeReserved(nc.Password) + "&";
postData += GoogleAuthentication.Source + "=" +
Utilities.UriEncodeReserved(this.factory.ApplicationName) + "&";
postData += GoogleAuthentication.Service + "=" +
Utilities.UriEncodeReserved(this.factory.Service) + "&";
if (this.factory.CaptchaAnswer != null)
{
postData += GoogleAuthentication.CaptchaAnswer + "=" +
Utilities.UriEncodeReserved(this.factory.CaptchaAnswer) + "&";
}
if (this.factory.CaptchaToken != null)
{
postData += GoogleAuthentication.CaptchaToken + "=" +
Utilities.UriEncodeReserved(this.factory.CaptchaToken) + "&";
}
postData += accountType;
byte[] encodedData = encoder.GetBytes(postData);
authRequest.ContentLength = encodedData.Length;
Stream requestStream = authRequest.GetRequestStream() ;
requestStream.Write(encodedData, 0, encodedData.Length);
requestStream.Close();
authResponse = authRequest.GetResponse();
}
catch (WebException e)
{
Tracing.TraceMsg("QueryAuthtoken failed " + e.Status + " " + e.Message);
authResponse = e.Response;
}
HttpWebResponse response = authResponse as HttpWebResponse;
if (response != null)
{
// check the content type, it must be text
if (!response.ContentType.StartsWith(HttpFormPost.ReturnContentType))
{
throw new GDataRequestException("Execution of authentication request returned
unexpected content type: " + response.ContentType, this.Response);
}
// verify the content length. This should not be big, hence a big result might
indicate a phoney
if (response.ContentLength > 1024)
{
throw new GDataRequestException("Execution of authentication request returned
unexpected large content length: " + response.ContentLength, this.Response);
}
TokenCollection tokens =
Utilities.ParseStreamInTokenCollection(response.GetResponseStream());
authToken = Utilities.FindToken(tokens, GoogleAuthentication.AuthToken);
if (authToken == null)
{
throw getAuthException(tokens);
}
// failsafe. if getAuthException did not catch an error...
int code= (int)response.StatusCode;
if (code != 200)
{
throw new GDataRequestException("Execution of authentication request returned
unexpected result: " +code, this.Response);
}
}
Tracing.Assert(authToken != null, "did not find an auth token in
QueryAuthToken");
if (authResponse != null)
{
authResponse.Close();
}
return authToken;
}
----- Original Message ----
From: Lane LiaBraaten (Google) <[EMAIL PROTECTED]>
To: Google Calendar Data API <[email protected]>
Sent: Wednesday, July 11, 2007 7:45:25 PM
Subject: Re: New Google Bug
Hi Kulvinder,
In Fidder the Session Inspector will allow you to view the network
traffic. Look at the 'Raw' view and see if you can find the packet
that is causing the error. Then post the request and response that
caused the problem -- be sure not to post and private data!
BTW - Did you try the workaround I posted?
Cheers,
Lane
On Jul 11, 6:20 am, Kulvinder Singh <[EMAIL PROTECTED]> wrote:
> Hi Lane,
>
> I have installed Fiddler on my machine. What all information you need to
> debug the problem ?
>
> Regards
> Kulvinder Singh
>
> ----- Original Message ----
> From: Kulvinder Singh <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Wednesday, July 11, 2007 6:10:32 PM
> Subject: Re: New Google Bug
>
> Hi Lane,
>
> The error occured when i try to fetch an autheticated feed from Google
> Calendar through C#.NET API 1.0.9.8 library.
>
> Can you help ?
>
> Regards
> Kulvinder Singh
>
> ----- Original Message ----
> From: Lane LiaBraaten (Google) <[EMAIL PROTECTED]>
> To: Google Calendar Data API <[email protected]>
> Sent: Tuesday, July 10, 2007 7:09:54 PM
> Subject: Re: New Google Bug
>
> Hi Kulvinder,
>
> Sorry for the delay. Looks like that error is caused by bad
> formatting in a server response. Can you post some more details about
> what operation you are performing when you receive this error?
>
> In the meantime, there is a workaround. Check out the solution at:
>
> http://www.cookcomputing.com/blog/archives/000556.html
>
> Hope that helps,
> Lane
>
> On Jul 9, 11:00 pm, "Kulvinder Singh" <[EMAIL PROTECTED]>
> wrote:
> > I think its more than 2 weeks and nobody from Google responded to this.
>
> > On 6/25/07, Kulvinder Singh <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I got the following error from Google server :
>
> > > *The server committed a protocol violation.*
>
> > > *Section=ResponseHeader Detail=CR must be followed by LF*
>
> > > Can anybody tell me the reason for this ?
>
> > > Regards
>
> > > Kulvinder Singh
>
> > > ------------------------------
> > > 8:00? 8:25? 8:40? Find a flick in no time
> > > with theYahoo! Search movie showtime shortcut.
>
> Now that's room service! Choose from over 150,000 hotels
> in 45,000 destinations on Yahoo! Travel to find your fit.
>
> ____________________________________________________________________________________
> Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail,
> news, photos & more.http://mobile.yahoo.com/go?refer=1GNXIC
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the
tools to get online.
http://smallbusiness.yahoo.com/webhosting
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---