Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: client/utils/auth_server.py

Issue 2963103002: Always treat TokenError as fatal error. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/tests/auth_server_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/utils/auth_server.py
diff --git a/client/utils/auth_server.py b/client/utils/auth_server.py
index 7653a4c93803ee004f2a518eacc4027ad7712b51..99f7210d3c3d9fd69de524540b5aafbcb15b3fce 100755
--- a/client/utils/auth_server.py
+++ b/client/utils/auth_server.py
@@ -24,15 +24,14 @@ AccessToken = collections.namedtuple('AccessToken', [
class TokenError(Exception):
- """Raised by TokenProvider if the token can't be created.
+ """Raised by TokenProvider if the token can't be created (fatal error).
See TokenProvider docs for more info.
"""
- def __init__(self, code, msg, fatal=False):
+ def __init__(self, code, msg):
super(TokenError, self).__init__(msg)
self.code = code
- self.fatal = fatal
class RPCError(Exception):
@@ -60,9 +59,9 @@ class TokenProvider(object):
low-level or transient errors.
Can also raise TokenError. It will be converted to GetOAuthToken reply with
- non-zero error_code. It will also optionally be cached, so that the provider
- would never be called again for the same set of scopes. This is appropriate
- for high-level or fatal errors.
+ non-zero error_code. It will also be cached, so that the provider would
+ never be called again for the same set of scopes. This is appropriate for
+ high-level fatal errors.
Returns AccessToken on success.
"""
@@ -251,11 +250,10 @@ class LocalAuthServer(object):
except TokenError as exc:
tok_or_err = exc
# Cache the token or fatal errors (to avoid useless retry later).
- if isinstance(tok_or_err, AccessToken) or tok_or_err.fatal:
- with self._lock:
- if not self._server:
- raise RPCError(503, 'Stopped already.')
- self._cache[cache_key] = tok_or_err
+ with self._lock:
+ if not self._server:
+ raise RPCError(503, 'Stopped already.')
+ self._cache[cache_key] = tok_or_err
# Done.
if isinstance(tok_or_err, AccessToken):
« no previous file with comments | « client/tests/auth_server_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698