Ebeo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Utilities.QueryClientLoginToken incorrect proccess WebExcpetion #447

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to use Utilities.QueryClientLoginToken with incorrect username or 
password.

What is the expected output? What do you see instead?
Exception of type InvalidCredentialsException or CaptchaRequiredException 
should be raised. Instead, exception of type WebRequest are raised.

Please use labels and text to provide additional information.
In the source code of the method Utilities.QueryClientLoginToken there are 
incorrect catch block:
public static string QueryClientLoginToken(GDataCredentials gc, string 
serviceName, string applicationName, bool fUseKeepAlive, Uri 
clientLoginHandler) {
...
try{
.....
response = request.GetResponse();
}
  catch (WebException)
    {
        throw;
    }
...
//process response and call  throw getAuthException(tokens, response2);
//This code will be never executed, if server return code different from 200.

}
But actually, this code should be like this:
try{
.....
response = request.GetResponse();
}
  catch (WebException e)
    {
            HttpWebResponse response = e.Response as HttpWebResponse;
            if (response == null)
                return;
          //process response and call throw getAuthException(tokens, response) at this place. So, the WebException will be converted in more appropriate exception

    }
}

Original issue reported on code.google.com by dima.fil...@gmail.com on 26 Nov 2010 at 7:38

GoogleCodeExporter commented 9 years ago
I too am having this exact problem.  When I enter an incorrect user email 
and/or password I'm getting a WebException (403 forbidden), but I should be 
getting InvalidCredentialsException.  My workaround is to treat 403 
WebExceptions as if they are caused by an invalid email or pass and prompt the 
user to retry.  I really don't feel good about this, as I'm sure there are 
other reasons to get a 403 exception.

Please respond and look into this!  

By the way, I'm using the Calendar API (version 1.7.0.1).  Please let me know 
if you need any more info.

Original comment by stephani...@macefusion.com on 25 Jan 2011 at 10:07

GoogleCodeExporter commented 9 years ago

Original comment by ccherub...@google.com on 25 Jan 2011 at 11:08

GoogleCodeExporter commented 9 years ago
Fixed in rev. 1066, thanks for suggesting this fix.

Original comment by ccherub...@google.com on 26 Jan 2011 at 6:08