Index: third_party/upload.py |
diff --git a/third_party/upload.py b/third_party/upload.py |
index 0aae84c1ea3dcaa8e76fdd71b6c9c0c2dd2709e4..f3100211c216fed08f82d28e73208d19e8f4c140 100755 |
--- a/third_party/upload.py |
+++ b/third_party/upload.py |
@@ -289,7 +289,7 @@ class AbstractRpcServer(object): |
req.add_header(key, value) |
return req |
- def _GetAuthToken(self, email, password): |
+ def _GetAuthToken(self, email, password, internal=False): |
"""Uses ClientLogin to authenticate the user, returning an auth token. |
Args: |
@@ -307,8 +307,9 @@ class AbstractRpcServer(object): |
if self.host.endswith(".google.com"): |
# Needed for use inside Google. |
account_type = "HOSTED" |
+ service = ('ClientLogin') if not internal else ('ClientAuth') |
req = self._CreateRequest( |
- url="https://www.google.com/accounts/ClientLogin", |
+ url="https://www.google.com/accounts/%s" % (service,), |
data=urllib.urlencode({ |
"Email": email, |
"Passwd": password, |
@@ -373,9 +374,18 @@ class AbstractRpcServer(object): |
""" |
for i in range(3): |
credentials = self.auth_function() |
+ |
+ # Try external, then internal. |
+ exc = None |
try: |
auth_token = self._GetAuthToken(credentials[0], credentials[1]) |
- except ClientLoginError, e: |
+ except urllib2.HTTPError: |
+ try: |
+ auth_token = self._GetAuthToken(credentials[0], credentials[1], |
+ internal=True) |
+ except ClientLoginError, e: |
+ exc = e |
+ if exc: |
print >> sys.stderr, '' |
if e.reason == "BadAuthentication": |
Vadim Sh.
2015/04/07 17:31:10
this things may be different for ClientAuth. Try e
|
if e.info == "InvalidSecondFactor": |
@@ -409,7 +419,7 @@ class AbstractRpcServer(object): |
print >> sys.stderr, "The service is not available; try again later." |
else: |
# Unknown error. |
- raise |
+ raise exc |
print >> sys.stderr, '' |
continue |
self._GetAuthCookie(auth_token) |