Author: fmantek
Date: Mon Oct 15 04:18:32 2007
New Revision: 294

Modified:
   trunk/clients/cs/src/core/gauthrequest.cs

Log:
Fixed gauthrequest to create a more meaningfull exception if the 
authentication request failed due to a wrong http error response (like 
proxy gateway)

Modified: trunk/clients/cs/src/core/gauthrequest.cs
==============================================================================
--- trunk/clients/cs/src/core/gauthrequest.cs   (original)
+++ trunk/clients/cs/src/core/gauthrequest.cs   Mon Oct 15 04:18:32 2007
@@ -512,12 +512,13 @@
                 {
                      throw new GDataRequestException("Execution of 
authentication request returned unexpected large content length: " + 
response.ContentLength, response);
                 }
+
                 TokenCollection tokens = 
Utilities.ParseStreamInTokenCollection(response.GetResponseStream());
                 authToken = Utilities.FindToken(tokens, 
GoogleAuthentication.AuthToken);
-
+
                 if (authToken == null)
                 {
-                    throw getAuthException(tokens);
+                    throw getAuthException(tokens, response);
                 }
                 // failsafe. if getAuthException did not catch an error...
                 int code= (int)response.StatusCode;
@@ -542,12 +543,17 @@
         /// values from the login URI handler.
         /// </summary>
          /// <param name="tokens">The tokencollection of the parsed 
return form</param>
+        /// </// <param name="response">the  webresponse</param>
         /// <returns>AuthenticationException</returns>
-        private AuthenticationException 
getAuthException(TokenCollection tokens)
+        private LoggedException getAuthException(TokenCollection 
tokens,  HttpWebResponse response)
         {
-
             String errorName = Utilities.FindToken(tokens, "Error");
-
+            int code= (int)response.StatusCode;
+            if (errorName == null || errorName.Length == 0)
+            {
+               // no error given by Gaia, return a standard 
GDataRequestException
+                throw new GDataRequestException("Execution of 
authentication request returned unexpected result: " +code,  response);
+            }
             if ("BadAuthentication".Equals(errorName))
             {
                 return new InvalidCredentialsException("Invalid credentials");

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

Reply via email to