Index: auth.py |
diff --git a/auth.py b/auth.py |
index 70e706e45f43cd1ec8191075f1e4eae2ec9f2006..c5e3b851f522b8e7b802738bb683e77b759d50c7 100644 |
--- a/auth.py |
+++ b/auth.py |
@@ -219,11 +219,14 @@ def get_authenticator_for_host(hostname, config): |
# Append some scheme, otherwise urlparse puts hostname into parsed.path. |
if '://' not in hostname: |
hostname = 'https://' + hostname |
+ scopes = OAUTH_SCOPES |
+ if hostname == 'https://code.google.com': |
Vadim Sh.
2015/06/11 01:37:31
make it a top-level config-like dict, so it looks
seanmccullough
2015/06/11 02:05:22
Done.
|
+ scopes = "%s https://www.googleapis.com/auth/projecthosting" % scopes |
parsed = urlparse.urlparse(hostname) |
if parsed.path or parsed.params or parsed.query or parsed.fragment: |
raise AuthenticationError( |
'Expecting a hostname or root host URL, got %s instead' % hostname) |
- return Authenticator(parsed.netloc, config) |
+ return Authenticator(parsed.netloc, config, scopes) |
class Authenticator(object): |
@@ -235,7 +238,7 @@ class Authenticator(object): |
config: AuthConfig object that holds authentication configuration. |
""" |
- def __init__(self, token_cache_key, config): |
+ def __init__(self, token_cache_key, config, scopes): |
assert isinstance(config, AuthConfig) |
assert config.use_oauth2 |
self._access_token = None |
@@ -243,6 +246,7 @@ class Authenticator(object): |
self._lock = threading.Lock() |
self._token_cache_key = token_cache_key |
self._external_token = None |
+ self._scopes = scopes |
if config.refresh_token_json: |
self._external_token = _read_refresh_token_json(config.refresh_token_json) |
logging.debug('Using auth config %r', config) |
@@ -487,7 +491,7 @@ class Authenticator(object): |
logging.debug('Requesting user to login') |
raise LoginRequiredError(self._token_cache_key) |
logging.debug('Launching OAuth browser flow') |
- credentials = _run_oauth_dance(self._config) |
+ credentials = _run_oauth_dance(self._config, self._scopes) |
_log_credentials_info('new token', credentials) |
logging.info( |
@@ -560,7 +564,7 @@ def _log_credentials_info(title, credentials): |
}) |
-def _run_oauth_dance(config): |
+def _run_oauth_dance(config, scopes): |
"""Perform full 3-legged OAuth2 flow with the browser. |
Returns: |
@@ -572,7 +576,7 @@ def _run_oauth_dance(config): |
flow = client.OAuth2WebServerFlow( |
OAUTH_CLIENT_ID, |
OAUTH_CLIENT_SECRET, |
- OAUTH_SCOPES, |
+ scopes, |
approval_prompt='force') |
use_local_webserver = config.use_local_webserver |